我有一個簡單的使用案例 - 我有一個豐富的對象模型,我在AngularDart應用程序中使用,並且我想要一個組件向我顯示模型的其中一個的當前狀態字段和我想在選擇更改時調用模型上的方法(最終將更新綁定到的字段)。裝訂材料 - 選擇我的模型
事情是這樣的:
APP-component.dart:
@Component(
selector: 'my-app',
styleUrls: const ['app_component.css'],
templateUrl: 'app_component.html',
directives: const [CORE_DIRECTIVES, materialDirectives],
providers: const [materialProviders],
)
class AppComponent {
Model myModel = new MyModel();
SelectionModel<String> selectModel = new SelectionModel();
}
APP-component.html:
<material-dropdown-select
[options]='myModel.listOfOptions'
[buttonText]='myModel.currentOption'
[selection]='selectModel'>
<!-- call myModel.changeOption(selectedOption) when selection changes -->
</material-dropdown-select>
我還是有點困惑......誰打電話給二傳手? – mjeffw
當您選擇新值時,該框架會執行此操作。 –
我知道我可能很密集,但是像這樣? SelectionModel _selectModel = new SelectionModel(); SelectionModel get selectModel {return _selectModel; } set selectModel(SelectionModel model){ _selectModel = model; _selectModel.selectionChanges.listen(updateSelection); } 如果是這樣,它不工作。響應於更改選擇,setter不會被調用。 –
mjeffw