angularjs - Call function in ng-if -
i have situation want call function display correct html mark up. here current code:
<li ng-repeat="data in myblock.mydata"> <div ng-if="data.type=='jonh'"> <div class='row'> <div class='col'> text jonh </div> </div> </div> <div ng-if="data.type=='roy'"> <div class='row'> <div class='col'> roy have different text </div> </div> </div> <div ng-if="data.type=='kevin'" > <div class='row'> <div class='col'> kevin text different </div> </div> </div> </li> i combine ngif function called "showfield(name)" check , return right html mark up. how done? final html mark should this:
<li ng-repeat="data in myblock.mydata"> <div ng-if="showfield(data.type)"> //not sure how implement part </div> </li>
html:
<li ng-repeat="data in myblock.mydata"> <div ng-if="checkvaliddatatype(data.type)"> <div class='row'> <div class='col'> <label class='title' for="{{data.name}}">{{data.label}}</label> <span class="{{data.type.tolowercase() + 'class'}}">this {{data.type}}</span> </div> </div> </div> </li> js:
$scope.checkvaliddatatype = function(type) { return type === "roy" || type === "kevin" || type === "jonh"; }
Comments
Post a Comment