<div ng-app="" ng-init="click=false"> <button ng-click="click= !click">我变</button> <p ng-hide="click">显示了。</p> <p ng-hide="!click">隐藏了。</p> </div>
<div ng-app="" ng-init="friends = [
{name:‘Tom‘, age:25},
{name:‘Jerry‘, age:28},
{name:‘Tom‘, age:25},
{name:‘Jerry‘, age:28}]">
<table>
<tbody><tr ng-repeat="x in friends">
<td> {{ ‘Name:‘+ x.name +‘ ,Age:‘+ x.age}} </td>
</tr>
</tbody></table>
</div>
使用AngularJS过滤器可以实现对字符串的大小写转换、货币格式的转换、数组的过滤等等。
过滤器可以使用一个管道字符(|)添加到表达式和指令中。常用的有:
<div ng-app="" ng-controller="personController"> <p>姓名为 {{ person.lastName | uppercase }}</p> </div>
<div ng-app="" ng-controller="namesController"> <p>输入过滤:</p> <p><input type="text" ng-model="name"></p> <ul> <li ng-repeat="x in names | filter:name | orderBy:‘country‘"> {{ (x.name | uppercase) + ‘, ‘ + x.country }} </li> </ul> </div>
原文:http://www.cnblogs.com/qingwen/p/4986135.html