码迷,mamicode.com
首页 > 其他好文 > 详细

angular中对象与字符串之间的转换

时间:2017-06-27 10:02:55      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:strong   arp   watch   doc   sha   asc   foreach   span   run   

1.angular 里 字符串与对象互转 

    angular.toJson();将字符串转成对象

    angular.forJson(); 将字符串转成对象

 2.angular 循环

  

  <script src="../js/angular.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
        var json = {
            "name":"jack",
            "age":20
        }
        var arr = [];
//      angular 循环 value key
        angular.forEach(json,function(val,key){
            this.push(val + ‘:‘ +key);
             
        },arr);
        console.log(arr)
    </script>

4.手动启动angular的方法   也可开启多个模块

    angular.element(document).on(‘click‘,function(){

  angular.bootstrap(document,[‘mk‘])

  })

5.app.run();  可以不使用控制器就开启数据,但适合$rootscope;  

app.run([‘rootScope‘,function($rootScope){       
  
}])
6.disable : true ,禁用

7.$watch监听

$scope.$watch(‘要监听的对象‘,function(newVal,oldVal){
 
},true)
true 深度监听

angular中对象与字符串之间的转换

标签:strong   arp   watch   doc   sha   asc   foreach   span   run   

原文地址:http://www.cnblogs.com/w-xiaojia/p/7083210.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!