标签:blog http io 使用 java ar strong for 数据
如:{{1+2}}
过滤器就是用来过滤变量值,支持链式的写法如下:
{{ expression | filterName : parameter1 : ...parameterN }}
currency,date,filter,json,limitTo,lowercase,number,orderBy,uppercase
{{ 12.0 | currency:"USD$" }} {{12.9 | currency | number:0 }} {{ 1304375948024 | date }} {{ 1304375948024 | date:"MM/dd/yyyy @ h:mma" }} {{ "lower cap string" | uppercase }} {{ {foo: "bar", baz: 23} | json }} ng-repeat="phone in phones | filter:query | orderBy:orderProp"
filter xxx, 可以根据网页中输入的xxx值进行过滤和, 增强了页面的交互效果
orderBy 过滤 器以一个数组作为输入,复制一份副本,然后把副本重排序再输出到迭代器
只需要通过app.filter定义需要的filter即可。
var app = angular.module(‘myapp‘, []); app.filter(‘filter3‘,function(){ return function(items){ angular.forEach(items,function(item){ item = item + ‘!‘ }); return items; } });
以下用不同的方式匹配到ngBind指令
<span ng:bind="name"> angular <span ng_bind="name"> angular <span ng-bind="name"> angular <span data-ng-bind="name"> angular <span x-ng-bind="name"> angular
Angular内部提供的指令基本都能匹配属性名,标签名,注释,或者类名, 如:
<my-dir></my-dir> <span my-dir="exp"></span> <!-- directive: my-dir exp --> <span class="my-dir: exp;"></span>
//html <div ng-controller="Ctrl"> <my-customer customer="naomi"></my-customer> </div> //js var app = angular.module(‘testTpl‘, []); app.controller(‘Ctrl‘, function($scope) { $scope.naomi = { name: ‘Naomi‘, address: ‘1600 Amphitheatre‘ }; $scope.vojta = { name: ‘Vojta‘, address: ‘3456 Somewhere Else‘ }; }); app.directive(‘myCustomer‘, function() { return { transclude: true, restrict: ‘ACE‘, templateUrl: ‘my-customer.html‘, scope: { customer: ‘=‘ }, controller: function() { return { openApi: function() { console.log(‘api init‘); } } } }; }); app.directive(‘myCustomer1‘, function() { return { transclude: true, restrict: ‘ACE‘, require: ‘^myCustomer‘, templateUrl: ‘my-customer.html‘, scope: { customer: ‘=‘ }, link: function(scope, element, attrs, myCustomer) { //因为使用了require, 会多增加一个参数myCustomer来调用myCustomer指令控制器开放的API } }; }); // my-customer.html Name: {{customer.name}} Address: {{customer.address}} <hr> Name: {{vojta.name}} Address: {{vojta.address}}
require: ‘^‘前缀意味着指令在它的父元素上面搜索控制器, 默认会在自身的元素上面搜索指定的指令
参考
标签:blog http io 使用 java ar strong for 数据
原文地址:http://www.cnblogs.com/mininice/p/3985836.html