Can I declare ng-repeat elements inside of javascript

Is it possible to declare ng-repeat elements inside of javascript.
I googled try to find the answer but I could not find. If other ways is there please give some ideas I am really lost my way right now.
Thank you

HTML

<div class="" ng-app='app' ng-controller='appCtrl'>
    <div ng-repeat='el in names'>
        <div ng-class="class">{{el.name}}</div>
    </div>
</div>

JavaScript

var app = angular.module('app', [])
var appCtrl = function ($scope) {
    $scope.names = [{
        name: 'jane'
    }, {
        name: 'jane1',
        name: 'jane2'
    }, {
        name: 'jane3'
    }];
    $scope.class = {
        // I want to declare this part 
        //
        //
        // if (el.length() == 2) {
        //     alert('true')
        // }
    }
}

app.controller('appCtrl', appCtrl())

FIDDLE


Source: javascript

Leave a Reply