examples(lifecycle-hooks): update Dart sample to match TS (#2281)
Make equivalent TS code changes to Dart sample. This sync’s Dart with all #2177 changes pertinent to Dart. E2E tests pass now for Dart, Suites passed: - public/docs/_examples/lifecycle-hooks/ts
This commit is contained in:
parent
51bcce6b1c
commit
d24ff43728
|
@ -1,6 +1,4 @@
|
|||
// #docregion
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:angular2/core.dart';
|
||||
|
||||
class Hero {
|
||||
|
@ -23,7 +21,7 @@ class Hero {
|
|||
'.hero {background: LightYellow; padding: 8px; margin-top: 8px}',
|
||||
'p {background: Yellow; padding: 8px; margin-top: 8px}'
|
||||
])
|
||||
class DoCheckComponent implements DoCheck, OnChanges {
|
||||
class DoCheckComponent implements DoCheck {
|
||||
@Input()
|
||||
Hero hero;
|
||||
@Input()
|
||||
|
@ -72,16 +70,6 @@ class DoCheckComponent implements DoCheck, OnChanges {
|
|||
}
|
||||
// #enddocregion ng-do-check
|
||||
|
||||
// Copied from OnChangesComponent
|
||||
ngOnChanges(Map<String, SimpleChange> changes) {
|
||||
changes.forEach((String propName, SimpleChange change) {
|
||||
String cur = JSON.encode(change.currentValue);
|
||||
String prev =
|
||||
change.isFirstChange() ? "{}" : JSON.encode(change.previousValue);
|
||||
changeLog.add('$propName: currentValue = $cur, previousValue = $prev');
|
||||
});
|
||||
}
|
||||
|
||||
void reset() {
|
||||
changeDetected = true;
|
||||
changeLog.clear();
|
||||
|
|
Loading…
Reference in New Issue