2
我有以下情況。我有兩個共享相同模型的Angular組件。如何觀察模型更改並更新AngularDart中的某些屬性?
在某些時候第一部分更新shared
模型,我希望能夠挑選更新在我的第二個組成部分。我試着做類似:
@NgComponent(...)
class MySecondComponent {
Scope scope;
NgModel ngModel;
String someValue;
MySecondComponent(this.ngModel, this.scope) {
imagsomeValueeUrl = ngModel.modelValue;
scope.$watch('ngModel.modelValue', (newValue, oldValue, _this) {
someValue = newValue;
});
}
}
有什麼建議嗎?
好像我想通了。我使用'''ctrl.ngModel.modelValue'''而不是''ngModel.modelValue'''。不知道這是不是處理這個用例的最好方法,儘管.... – markovuksanovic