I know this question sounds redundant but I'm learning angular and would it be possible to create a link if a condition met is true or would I just have to do all the work on the front end?
$scope.no_animal_number = function('animalnumber'){
var noassignednumber;
if(noassignednumber == ''){
noassignednumber = "{{ l.animaltype }}";
}if(nocode == 'animalnumber')
nocode = "<a href="site.php?site={{ l.animalnumber }}">{{ l.animaltype }}</a>";
}
return noassignednumber;
}
<tr ng-repeat="l in animal_list">
<td>{{ l.animalnumber }}</td>
<td>{{ no_animal_number(l.animaltype) }}</td>
</tr>
this was my attempt at creating a function to do this.
答案 0 :(得分:1)
你的问题有点令人困惑,因为你是从你的视图中调用一个函数,但是你在控制器上创建该函数的方式看起来不会起作用。
以下是我推荐的内容(或根据您的具体需求进行类似):
<tr ng-repeat="l in animal_list">
<td>{{l.animalnumber}}</td>
<td>
<span ng-if="l.animalnumber">{{l.animaltype}}</span>
<span ng-if="!l.animalnumber">
<a href="site.php?site={{l.animaltype}}">{{l.animaltype}}</a>
</span>
</td>
</tr>