我有一个带有单个属性的组件。我想用派生自该属性的值填充组件中的字段。我遇到的问题是,当构造函数内的代码运行时,没有发生与属性的绑定。那么,如何设置派生字段的值呢?
这是一些代码:
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);
}