var getter = $parse('user.name');
var setter = getter.assign;
var context = {user: {name: 'John Doe'};
var locals = {user: {name: 'Doe John'};
getter(context); //John Doe
setter(context, 'new name');
getter(context); //new name
getter(context, locals); //Doe John
var scope = $rootscope.$new(true);
scope.a = 1;
scope.b = 2;
scope.$eval('a + b')//3
scope.$eval(function(scope){
return scope.a + scope.b;
});//3
$eval: function(expr, locals){
return $parse(expr)(this, locals);
}
//html
<div book="{{book.name}}"></div>
//js
attrs.$observe('book', function(newValue){
//just have one parameter, can't get old value
});
scope.$watch(attrs.book, function(newValue, oldValue){
//get undefined
});
//html
<div book="book.name"></div>
//js
attrs.$observe('book', function(newValue){
//always get 'book.name'
});
scope.$watch(attrs.book, function(newValue, oldValue){
});
$scope.teamScore = 0;
$scope.time = 0;
$scope.$watchGroup(['teamScore', 'time'], function(newVal, oldVal) {
//newVal and oldVal are both array
});
$scope.names = ['igor', 'matias', 'misko', 'james'];
$scope.dataCount = 4;
$scope.$watchCollection('names', function (newVal, oldVal) {
$scope.dataCount = newVal.length;
});
$timeout(function(){
$scope.names.pop();
},2000);
var off = scope.$watch('name', function(newValue, oldValue){
});
off();
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有