【发布时间】:2017-08-02 22:53:26
【问题描述】:
我有一个包含 3 个对象的数组,然后是 1 个对象(或更多,取决于 3 个第一个对象的选择),然后是 5 个数组(或更多,取决于 5 个数组的选择)
repeat="item in $ctrl.project[$ctrl.checkProject()].productType[$ctrl.ckeckProductType()]
//method to search for the item
checkProject() {
if (this.project.label === 'business') {
return 0
} else if(this.project.label === 'realEstate') {
return 1
} else if (this.project.label === 'smallBusiness'){
return 2
}
}
ckeckProductType() 方法也是如此
难道没有更复杂的解决方案来激发这一切吗?
【问题讨论】:
-
当然 - 在控制器中运行这两个函数只运行一次,而不是
return 0/1/2;保存值:this.project_label = this.checkProject();和this.project_type = this.ckeckProductType();然后在循环中,使用那些属性:item in $ctrl.project[$ctrl.project_label].productType[$ctrl.project_type]
标签: javascript angularjs angularjs-ng-repeat ui-select