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


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  深度監聽


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM