日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

angularjs 工具方法

發(fā)布時間:2023/12/20 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 angularjs 工具方法 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
<!DOCTYPE HTML> <html ng-app> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>無標題文檔</title> <script src="angular.min.js"></script> <script>//angular.bind(); -> $.proxy() : 改this指向 function show(n1,n2){alert(n1);alert(n2);alert(this); } angular.bind(document,show,3)(4);//改變show函數的this指向,//angular.copy(); //拷貝對象 var a = {name : 'hello'}; var b = {age : '20'}; var c = angular.copy(a,b); //a把所有值覆蓋給了b console.log(b);//angular.extend(); //對象繼承 var a = {name : 'hello' }; var b = {age : '20' }; var c = angular.extend(b,a); //c有 console.log(b); </script> </head> <body> </body> </html> <!DOCTYPE HTML> <html ng-app> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>無標題文檔</title> <script src="jquery-1.11.1.js"></script> <script src="angular.min.js"></script> <script>var a = []; console.log(angular.isArray(a));//是不是數組 window.onload = function(){console.log(angular.isElement( document.body ));console.log(angular.isElement( $(document.body) )); };console.log(angular.version); var a = NaN; var b = NaN; console.log(angular.equals(a,b)); var values = ['a','b','c']; var values = {'name':'hello','age':'20'}; var result = []; angular.forEach(values,function(value,i){console.log(value);console.log(i);this.push( value + i );//this是result },result); console.log(result);//JSON.parse() JSON.stringify() var str = '{"name":"hello","age":"20"}'; var json = angular.fromJson(str); console.log(json); var json = {"name":"hello","age":"20"}; var str = angular.toJson(json,true); console.log( str ); //angular.identity/noopvar str = 'hello'; console.log(angular.identity(str)); //hello function identity(str){return str; } console.log(angular.noop()); //undefined function noop(){ } console.log(angular.uppercase('hello')); </script> </head><body> <div id="div1">aaaaaaaa</div> <script> var oDiv = document.getElementById('div1'); $('#div1').css('background','red'); //angular.element === $ </script> </body> </html> <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>無標題文檔</title> <script src="angular.min.js"></script> <script>var m1 = angular.module('myApp1',[]); var m2 = angular.module('myApp2',[]);m1.controller('Aaa',['$scope',function($scope){//定義Aaa控制器的函數,$scope.name = 'hello'; }]); m2.controller('Bbb',['$scope',function($scope){$scope.name = 'hi'; }]);document.onclick = function(){var aDiv = document.getElementsByTagName('div');angular.bootstrap(aDiv[0],['myApp1']);angular.bootstrap(aDiv[1],['myApp2']); };</script> </head> <body> <div ng-controller="Aaa"><p>{{name}}</p> </div> <div ng-controller="Bbb"><p>{{name}}</p> </div> </body> </html> <!DOCTYPE HTML> <html ng-app> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>無標題文檔</title> <script src="angular.min.js"></script> <script>function Aaa($scope,$timeout){$scope.name = 'hello';setTimeout(function(){//$scope.name = 'hi';$scope.$apply(function(){//$apply針對數據變化有用$scope.name = 'hi';});},2000);$timeout(function(){$scope.name = 'hi';},2000);$scope.show = function(){$scope.name = 'hi';};}</script> </head><body> <!--<div ng-controller="Aaa" ng-click="name='hi'">--> <div ng-controller="Aaa" ng-click="show()"><p>{{name}}</p> </div></body> </html> <!DOCTYPE HTML> <html ng-app="myApp"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>無標題文檔</title> <script src="angular.min.js"></script> <script>var m1 = angular.module('myApp',[]);/*m1.controller('Aaa',['$scope',function($scope){//控制器的函數$scope.name = 'hello'; }]); m1.controller('Bbb',['$scope',function($scope){$scope.name = 'hi'; }]);*/ m1.run(['$rootScope',function($rootScope){ // $rootScope.name = 'hello'; }]); console.log( m1 );</script> </head><body> <div><p>{{name}}</p> </div></body> </html>

?

總結

以上是生活随笔為你收集整理的angularjs 工具方法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。