过滤器
使用一个管道字符(|)添加到表达式和指令中
currency
格式化数字为货币格式12345678< div ng-app="myApp" ng-controller="costCtrl">< input type="number" ng-model="quantity">< input type="number" ng-model="price">< p>总价 = {{ (quantity * price) | currency }}</p>< /div>
filter
从数组项中选择一个子集
|
|
lowercase
格式化字符串为小写
|
|
orderBy
根据某个表达式排列数组
|
|
uppercase
格式化字符串为大写
|
|
服务(Service)
- 服务是一个函数或对象
- 会一直监控应用,处理事件变化
$location
返回当前页面的 URL 地址, $location服务是作为一个参数传递到controller中,使用时需要在 controller中定义,使用 $location 服务比使用 window.location 对象更好
|
|
$http
向服务器发送请求,应用响应服务器传送过来的数据
|
|
$timeout
对应了 JS window.setTimeout 函数
|
|
$interval
对应了 JS window.setInterval 函数
|
|
创建自定义服务
|
|
Select(选择框) ng-options
|
|
ng-options 指令更适合创建下拉列表,使用 ng-options 的选项是一个对象, ng-repeat 是一个字符串
|
|
ng-options 操作对象
|
|
表格
- 表格显示序号可以在
中添加 $index:
|
|
使用 $even 和 $odd
|
|
HTML DOM
ng-disabled
指令直接绑定应用程序数据到 HTML 的 disabled 属性
|
|
ng-show
指令隐藏或显示一个 HTML 元素
|
|
ng-hide
指令用于隐藏或显示 HTML 元素