1
我有一个数组与3个对象,然后1个对象(或更多取决于3个第一个对象的选择),然后5个数组(或更多的根据5个数组的选择)Angular 1 - 复杂的ng重复对象/数组
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();'然后在循环中使用这些属性:$ ctrl.project [$ ctrl.project_label] .productType [$ ctrl.project_type] –