javascript - Angular JS - ngRepeat in a Template -



javascript - Angular JS - ngRepeat in a Template -

i'm trying utilize ngrepeat in directive - don't know how it. close?

mowers array in controller directive used.

.directive('slider', function() { homecoming function() { template: '<slider><film><frame ng-repeat="mower in mowers">{{mower.series}}</frame></film></slider>'; replace: true; scope: true; link: function postlink(scope, ielement, iattrs) { // jquery animate } } });

yes, you're close, syntax off. , need assign mowers on scope.

.directive('slider', function() { homecoming { restrict: 'e', //to element. template: '<film><frame ng-repeat="mower in mowers">{{mower.series}}</frame></film>', replace: true, scope: true, // creates new kid scope prototypically inherits link: function postlink(scope, ielement, iattrs) { scope.mowers = [ { series: 1 }, { series: 2 }, { series: 3 } ]; } } });

also, need not reference <slider> in itself.

the above code assumes you've made directives <film> , <frame>.

finally, if wanted pass mowers array in external scope, you'd alter scope setting this:

scope: { mowers: '=' }

and set so:

<slider mowers="mymowers"></slider>

where mymowers variable on controller or parent directive's scope.

i hope helps.

javascript angularjs

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -