angularjs 笔记之$watch
来源:互联网 发布:浙江师范大学行知学院 编辑:程序博客网 时间:2024/05/01 19:03
1.案例:总价大于100,免去运费:$watch
<body><div ng-app="myApp"> <div ng-controller="CartController"> <p>价格:<input type="text" ng-model="iphone.money"></p> <p>个数:<input type="text" ng-model="iphone.num"></p> <p>费用:<span>{{ sum() | currency:'¥' }}</span></p> <p>运费:<span>{{iphone.fre | currency:'¥'}}</span></p> <p>总额:<span>{{ sum() + iphone.fre | currency:'¥'}}</span></p> </div></div><script type="text/javascript"> var app = angular.module("myApp", []); app.controller('CartController',function($scope){ $scope.iphone = { money : 5, num : 1, fre : 10 }; $scope.sum = function(){ return $scope.iphone.money * $scope.iphone.num; }; $scope.$watch($scope.sum,function(newVal,oldVal){ $scope.iphone.fre = newVal >= 100 ? 0 : 10; }); });</script></body>
0 0
- angularjs 笔记之$watch
- angularJS之$watch用法
- angularjs $watch
- Angularjs实践之优化你的$watch
- AngularJS之$watch方法(监控动作)
- AngularJs学习笔记(4)--$scope里的$watch方法
- AngularJS 学习笔记(2)-MVC,$scope,$watch
- (12)AngularJS 1.X 之$watch和$apply方法
- angularjs-watch 监视事件
- 谈谈AngularJS中的$watch
- AngularJS $watch的用法
- angularjs中的$watch
- 《AngularJS》----$apply 与 $watch
- angularjs $watch 延迟处理
- AngularJS $watch用法
- angularjs中的$watch
- angularjs $watch $broadcast
- AngularJs之学习笔记
- hdu4111Alice and Bob+SG博弈
- Faster-RCNN+VGG用自己的数据集训练模型
- linux NAND驱动之三:6410平台上的NAND驱动加载
- Android那些你可能没了解过的---碎片化
- 第二周项目三-汉诺塔
- angularjs 笔记之$watch
- linux NAND驱动之四:6410上的NAND读写流程
- 软考网络工程师考试考点
- 设计模式
- Linux常用命令总结
- 编译boost程序出现如下错误fatal error LNK1104: cannot open file 'libboost_system-vc100-mt-gd-1_54.lib'的解决方法
- 嵌入式中的 *(volatile unsigned int *)理解
- RGB、YUV和YCbCr
- 水平出发和边缘出发的区别