利用angular自带工具函数,加快开发速度
-
angular.extend(obj,{})
扩充对象 -
angular.forEach([]/{},function(v,k){})
可以便利数组,也可遍历对象;第一个参数是value,第二个参数index或key值
var obj={
name:'xiongwei'
}
angular.extend(obj,{
age:27
})
console.log(obj)
<script type="text/javascript">
var app=angular.module('test',[])
app.controller('con1', ['$scope', function($scope){
$scope.arr=['apple','pear','orange']
$scope.arr.forEach(i=>console.log(i))
}])
var obj={
name:'xiongwei'
}
angular.extend(obj,{
age:27
})
console.log(obj)
</script>
其实没必要,用es6那2种方法直接遍历即可,angular.extend()
扩展对象到shi不错