我正在观察searchModel但是searchInvalid永远不会被触发。为什么是这样?另外,有没有办法可以观察所有searchModel属性而不必全部列出它们?
export default Ember.ArrayController.extend(InfiniteScroll.ControllerMixin, {
needs : ['search'],
searchModel: Ember.computed.alias("controllers.search.model"),
searchInvalid : function() {
this.transitionToRoute('search');
}.observes( 'searchModel.sortColumn', 'searchModel.sortDirection', 'searchModel.loadNumber',
'searchModel.vehicleRegistration', 'searchModel.driverName', 'searchModel.site',
'searchModel.fromPlanDate','searchModel.toPlanDate'), //is there a way to watch the entire model?
perPage: 25,
page : 1
});
更新
我只是使用以下语法来实现这一点:
searchModelBinding: "controllers.search.model",
答案 0 :(得分:3)
Ember不会观察到从未被抓过的财产。这有点奇怪,但它是一个懒惰的装载概念,有点不稳定。
export default Ember.ArrayController.extend(InfiniteScroll.ControllerMixin, {
foo: function(){
this.get('searchModel'); // prime the engines.
}.on('init'),
needs : ['search'],
searchModel: Ember.computed.alias("controllers.search.model"),
searchInvalid : function() {
this.transitionToRoute('search');
}.observes( 'searchModel.sortColumn', 'searchModel.sortDirection', 'searchModel.loadNumber',
'searchModel.vehicleRegistration', 'searchModel.driverName', 'searchModel.site',
'searchModel.fromPlanDate','searchModel.toPlanDate'), //is there a way to watch the entire model?
perPage: 25,
page : 1
});
不,没有任何方法可以观看模特的每个项目。