function Aaa($scope ,$rootScope){//依赖注入,形参不能改
$scope.name='hello world!!';
$rootScope.txt="nihao";//全局变量,
}
function Bbb($scope){
$scope.name='Bbb hello world!!';
}
<div ng-controller='Aaa'>
<p>{{name}}</p>
</div>
<div ng-controller="Bbb">
<span>{{txt}}</span>//会先在局部查找,然后在全局查找。
</div>
function Aaa($scope,$timeout){
$scope.name = 'hello';
/*setTimeout(function(){
$scope.name = 'hi';
},2000);*/
/*$timeout(function(){
$scope.name = 'hi';
},2000);*/
$scope.show = function(){
$scope.name = 'hi';
};
}
<div ng-controller="Aaa" ng-click="show()">
<p>{{name}}</p>
</div>
<span>{{all.money*all.num|currency:'@'}}</span>
$scope.$watch($scope.sum,function(newVal,oldVal){
//console.log(newVal);
//console.log(oldVal);
$scope.iphone.fre = newVal >= 100 ? 0 : 10;
});