Ayo Adesina
Ayo Adesina

Reputation: 2395

Umbraco 7 - Syntax Help - JS or Angular? - Loop through Umbraco Property Editors

I'm creating a custom section and in one of my controllers I am sucessfully creating an Arrary of propertyeditor objects.

In my view this is working

<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>

But What I really want to do is look through, now I know how I can do this is JS for loop, but I'm pretty sure there must be a angular way of doing it, I'm still getting to grips with Angular so please forgive my niavity.

Upvotes: 0

Views: 243

Answers (1)

Nicholas Tower
Nicholas Tower

Reputation: 84912

In Angularjs, you can loop through an array using ng-repeat. For example:

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

For more information, you can find the ng-repeat documentation here: https://docs.angularjs.org/api/ng/directive/ngRepeat

Upvotes: 1

Related Questions