我有一个组件只接受一个属性。我想使用从此属性派生的值填充组件中的字段。当运行构造函数中的代码时,我遇到了与属性的绑定没有发生的问题。那么,我如何设置派生字段的值?在角度飞镖组件中填充派生字段
下面是一些代码:
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);
}