angular中對象與字符串之間的轉換

1.angular 裏 字符串與對象互轉 

    angular.toJson();將字符串轉成對象javascript

    angular.forJson(); 將字符串轉成對象java

 2.angular 循環json

  
<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的方法   也可開啓多個模塊bootstrap

    angular.element(document).on('click',function(){app

  angular.bootstrap(document,['mk'])post

  })this

5.app.run();  能夠不使用控制器就開啓數據,但適合$rootscope;  spa

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

7.$watch監聽code

$scope.$watch( '要監聽的對象' ,function(newVal,oldVal){
 
}, true )
true  深度監聽
相關文章
相關標籤/搜索