Wypełnianie pól pochodnych w komponencie Angular Dart
Mam komponent, który pobiera pojedynczy atrybut. Chcę wypełnić pole w komponencie wartością pochodzącą z tego atrybutu. Wchodzę w problem polegający na tym, że powiązanie z atrybutem nie nastąpiło, gdy uruchomiony jest kod wewnątrz konstruktora. Jak więc ustawić wartość pola pochodnego?
Oto kod:
import 'package:angular/angular.dart';
@NgComponent(
selector: 'tokens',
templateUrl: './component.html',
cssUrl: './component.css',
publishAs: 'ctrl',
map: const {
'text' : '@text'
}
)
class TokensComponent {
String text;
// Derived field.
List<Token> tokens = new List<Token>();
TokensComponent() {
print('inside constructor, text = $text'); // $text is null.
}
}
class Token {
String char;
bool important;
Token(this.char, this.important);
}