html:<div ng-controller="FilterController as ctrl">js:angular.module('FilterInControllerModule', []).controller('FilterController', ['filterFilter', function(filterFilter) {this.array = [{name: 'asnowwolf'},{name: 'why520crazy'},{name: 'joe'},{name: 'ckken'},{name: 'lightma'},{name: 'FrankyYang'}];this.filteredArray = filterFilter(this.array, 'a');}]);这样可以通过ctrl.array来访问FilterController控制器里的array数组,可是我通过FilterController.array却访问不了,这是为什么?还有FilterController控制器里的this是不是指FilterController?
1 回答
习惯受伤
TA贡献885条经验 获得超1144个赞
1.问题出在"FilterController as ctrl",相当于实例化了一个controller,实例名位ctrl,所以你需要通过ctrl.array来访问。
2.this指FilterController
添加回答
举报
0/150
提交
取消