Angularjs 工具方法 以及使用jquery 以及模块的相互依赖
Angularjs 工具方法以及Angularjs中使用jquery
学习要点:
1.Angularjs 工具方法
2.Angularjs angular.element工具方法和使用jquery
3.模块的相互依赖
1.Angularjs 工具方法
自己研究:
angular.isArray
angular.isDate
angular.isDefined
angular.isUndefined
angular.isElement
angular.isFunction
angular.isNumber
angular.isObject
angular.isString
重点讲述:
简单
angular.uppercase 转换为大写
angular.lowercase 转换成小写
angular.equals 判断是不是相等
angular.extend angular.extend(a,b); /*a继承b*/
angular.fromJson 字符串转换成json
angular.toJson json转换成字符串
angular.copy angular.copy(a,b); /*a copy给b 替换b的内容*/ 复杂
angular.forEach
{"name":"hello","age":"20","sex":'男'},
{"name":"hello1","age":"210","sex":'男1'} ];
var results=[];
angular.forEach(json,function(val,key){
console.log(https://www.360docs.net/doc/273036796.html,);
// console.log(key);
this.push(key+'--'+val);
},results);
console.log(results);
angular.bind
//绑定对象,作为函数的上下文
var self={name:'张三'};
var f=angular.bind(self,function(age){
$https://www.360docs.net/doc/273036796.html,=https://www.360docs.net/doc/273036796.html,+' is '+age;
console.log($https://www.360docs.net/doc/273036796.html,);
});
f(30);
var f=angular.bind(self,function(age){
$https://www.360docs.net/doc/273036796.html,=https://www.360docs.net/doc/273036796.html,+' is '+age;
console.log($https://www.360docs.net/doc/273036796.html,);
},10);
f();
angular.bootstrap 动态绑定model
var app1 = angular.module("myApp1", []);
var app2 = angular.module("myApp2", []);
app1.controller('firstController',function($scope){ $https://www.360docs.net/doc/273036796.html,='张三';
});
app2.controller('secondController',function($scope){ $https://www.360docs.net/doc/273036796.html,='李四';
});
var div1=document.getElementById('div1');
var div2=document.getElementById('div2');
document.onclick=function(){
angular.bootstrap(div1,['myApp1']);
angular.bootstrap(div2,['myApp2']);
}
2.Angularjs angular.element工具方法和使用jquery
1.引入jquery库
2.按照以前方式使用
3.模块的相互依赖
var app1 = angular.module("myApp", ['myApp2']);
app1.controller('firstController',function($scope){
$https://www.360docs.net/doc/273036796.html,='张三';
});
var app2 = angular.module("myApp2", []);
app2.controller('secondController',function($scope){