angularjs - Load data from helpers before ng-class renders -


i'm working on project using meteor , angularjs.

i retrieve data using helpers, , used ng-repeat show them.

i'm using checklist-model (http://vitalets.github.io/checklist-model/) list of checkbox choices.

<li ng-repeat="t in types">   <div ng-class="nametagclass(t)">{{t.name}}</div>   <input type="checkbox" data-checklist-value="t"           data-checklist-model="chosentypes" class="sub-checkbox" /> </li> 

here ng-class function:

$scope.nametagclass=function(type){             if($scope.chosentypes.indexof(type)>-1){                 return "nametag active-nametag";             }              return "nametag";         } 

the problem is, when ng-class calls function, data chosentypes aren't loaded yet, checked elements don't "active-nametag" class. (however, when data loads , check element, class changes fine)

how can delay ng-class function call after data loaded?

just add ng-if in outer element this

<li ng-if="types" ng-repeat="t in types">   <div ng-class="nametagclass(t)">{{t.name}}</div>   <input type="checkbox" data-checklist-value="t" data-checklist-model="chosentypes" class="sub-checkbox" /> </li> 

Comments

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -