<!DOCTYPE html>
<html ng-app = "myApp">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
</style>
</head>
<body>
<div class="box" ng-controller = "myCtrl">
<p>价格:<input type="text" ng-model = "goods.price"/></p>
<p>个数:<input type="text" ng-model = "goods.num"/></p>
<p>运费:<span>{{goods.fee}}</span></p>
<p>费用:<span>{{fnNum() | currency : "¥"}}</span></p>
</div>
</body>
<script src="angular.min.js"></script>
<script src="angular-route.min.js"></script>
<script src="angular-ui-router.min.js"></script>
<script type="text/javascript">
var myApp = angular.module("myApp",[]);
myApp.controller("myCtrl",function($scope){
$scope.goods = {
price:5,
num:1,
fee:10
}
$scope.fnNum = function(){
return $scope.goods.price*$scope.goods.num
}
$scope.$watch($scope.fnNum,function(newFee){
if (newFee>=100) {
$scope.goods.fee = 0 ;
}else{
$scope.goods.fee = 10 ;
}
})
})
</script>
</html>