0

我正在创建一个自定义部分,并且在我的一个控制器中,我成功地创建了一个 propertyeditor 对象的数组。

在我看来,这是有效的

<umb-property property="vm.propertEditors[0]" ng-if="!vm.isNew">
    <umb-editor model="vm.propertEditors[0]"></umb-editor>
</umb-property>

<umb-property property="vm.propertEditors[1]" ng-if="!vm.isNew">
    <umb-editor model="vm.propertEditors[1]"></umb-editor>
</umb-property>

<umb-property property="vm.propertEditors[2]" ng-if="!vm.isNew">
    <umb-editor model="vm.propertEditors[2]"></umb-editor>
</umb-property>

但是我真正想要做的是看透,现在我知道我可以如何做到这一点是 JS for 循环,但我很确定必须有一种角度的方式来做到这一点,我仍然掌握 Angular 所以请原谅我的无知。

4

1 回答 1

1

在 Angularjs 中,您可以使用ng-repeat. 例如:

<umb-property ng-repeat="editor in vm.propertEditors" property="editor" ng-if="!vm.isNew">
    <umb-editor model="editor"></umb-editor>
</umb-property>

有关更多信息,您可以在此处找到 ng-repeat 文档:https ://docs.angularjs.org/api/ng/directive/ngRepeat

于 2017-09-19T16:18:21.117 回答