$watch函数的使用
来源:互联网 发布:贰贰网络面试 编辑:程序博客网 时间:2024/06/05 17:44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
var
firstController =
function
($scope){
$scope.name=
'张三'
;
$scope.count=0;
// 监听一个model 当一个model每次改变时 都会触发第2个函数
$scope.$watch(
'name'
,
function
(newValue,oldValue){
++$scope.count;
if
($scope.count > 30){
$scope.name =
'已经大于30次了'
;
}
});
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<!DOCTYPE html>
<
html
>
<
head
>
<
meta
charset
=
"utf-8"
>
</
head
>
<
body
>
<
div
ng-app
=
""
>
<
div
ng-controller
=
"firstController"
>
<
input
type
=
"text"
value
=
""
ng-model
=
"name"
/>
改变次数:{{count}}-{{name}}
</
div
>
</
div
>
<
script
type
=
"text/javascript"
src
=
"app/index.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"../../vendor/angular/angularjs.js"
></
script
>
</
body
>
</
html
>
1
2
3
4
$scope.data = {
name :
'李四'
,
count:20
}
1
2
3
$scope.$watch(
'data'
,
function
(){
},
true
)
阅读全文
0 0
- $watch函数的使用
- angular的$watch 函数
- gdb watch的使用
- watch的使用
- 高效的使用watch窗口
- 高效的使用watch窗口
- 高效的使用watch窗口
- gdb下watch的使用
- http watch的使用介绍
- grunt-watch插件的使用
- GDB 下 watch的使用
- kubernetes watch的使用源码
- 【AngularJS】释放多余的$watch检测函数
- VS2003监视窗口(watch)的使用
- VC++6.0调试:Watch窗口的使用
- angularJS使用$watch监控数据模型的变化
- Visual Studio中Image Watch的使用
- gdb 内存断点watch 的使用
- Python urllib.request 的使用
- VMware 虚拟机的虚拟磁盘编程知识点扫盲之二
- 21:苹果和虫子2
- 108: 求a*b
- 计算机、程序和Java概述
- $watch函数的使用
- 我的网址
- 【Linux学习笔记】24:Bash变量概述
- Eclipse用SOAP实现Web Service
- 使用libvirt和qemu将pci pass through设备添加到虚拟机上
- 多因子模型之因子(信号)测试平台----alphalens(三)
- 深入理解C++template的基础知识
- http keep-alive 和 tcp keepalive
- MyBatis(二)mapper 代理