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
|
// #docregion
|
||||||
import 'dart:convert';
|
|
||||||
|
|
||||||
import 'package:angular2/core.dart';
|
import 'package:angular2/core.dart';
|
||||||
|
|
||||||
class Hero {
|
class Hero {
|
||||||
@ -23,7 +21,7 @@ class Hero {
|
|||||||
'.hero {background: LightYellow; padding: 8px; margin-top: 8px}',
|
'.hero {background: LightYellow; padding: 8px; margin-top: 8px}',
|
||||||
'p {background: Yellow; padding: 8px; margin-top: 8px}'
|
'p {background: Yellow; padding: 8px; margin-top: 8px}'
|
||||||
])
|
])
|
||||||
class DoCheckComponent implements DoCheck, OnChanges {
|
class DoCheckComponent implements DoCheck {
|
||||||
@Input()
|
@Input()
|
||||||
Hero hero;
|
Hero hero;
|
||||||
@Input()
|
@Input()
|
||||||
@ -72,16 +70,6 @@ class DoCheckComponent implements DoCheck, OnChanges {
|
|||||||
}
|
}
|
||||||
// #enddocregion ng-do-check
|
// #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() {
|
void reset() {
|
||||||
changeDetected = true;
|
changeDetected = true;
|
||||||
changeLog.clear();
|
changeLog.clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user