javascript - AngularJS plugin initialization after ng repeat -


so using materializecss, , have piece of code:

<select> <option value="" disabled selected>jump season</option> <option option-item  ng-repeat="item in series.seasons" value="{{item.id}}"> {{item.name}} </option> </select> 

and im using directive:

.directive("optionitem", [function () { return {     restrict: 'a',     link: function (scope, element) {         if (scope.$last) {             $('select').material_select();         }     } }; }]); 

now elements repeat many times necessary, instead of displaying $scope.item.name value displaying {{item.name}} plain text, not expression value. how overcome setback? tried using material angular md-select experienced issues it, every time clicked select can't click on in webpage , nothing happens.


important note: series.seasons array fetched via ajax call.


set option-item directive on select

  <select option-item>        <option value="" disabled selected>jump season</option>        <option ng-repeat="item in users" value="{{item.id}}">            {{item.name}}         </option>   </select> 

and change directive

.directive("optionitem", ['$timeout', function ($timeout) {     return {         restrict: 'a',         link: function (scope, element) {             $timeout(function() { // wait ng-repeat                 $('select').material_select();             })         }     }; }]); 

http://jsfiddle.net/vorant/q9bkrzfo/5/


Comments