Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ayo Adesina 445 posts 1059 karma points
    Sep 19, 2017 @ 15:43
    Ayo Adesina
    0

    Syntax Help - JS or Angular - Loop through Property Editors.

    Hi Guys,

    This is potentially more of a stack over flow type question rather than a specfic Umbraco Question, so appoligies if it doesn't quite fit here.

    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.

    Thanks in Advance.

  • Ayo Adesina 445 posts 1059 karma points
    Sep 19, 2017 @ 17:00
    Ayo Adesina
    100

    Found the answer on stack overflow - For anyone else starting out on Angular...

    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

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies