Angularjs Practice Demo2

Source: Internet
Author: User

1 @{2Layout =NULL;3 }4 5<! DOCTYPE html>6 789<meta name= "viewport" content= "Width=device-width"/>Ten<title>ng Tools </title> One<script src= "~/scripts/angular.js" ></script> A<script type= "Text/javascript" src= "~/scripts/js/index2.js" ></script> - -<body> the<div ng-app= "MYAPP" > -<div ng-controller= "Firstcontroller" > - {{name}} - {{IsArray}} + {{name1}} - {{EQ}} +</div> A<div ng-controller= "Threecontroller" > at {{name}} -</div> -</div> -@******* Dynamic initialization of model↓**********@ -<div id= "Div1" ng-controller= "Firstcontroller" > - {{name}} in</div> -<div id= "Div2" ng-controller= "Secondcontroller" > to {{name}} +</div> -<script type= "Text/javascript" > the         varApp = Angular.module ("myApp", [' myApp3 ']);//Threecontroller defined in the Index2.js file *App.controller ("Firstcontroller",function($scope) { $$scope. Name = "Zhangsan";Panax Notoginseng$scope. arr = [1, 2, 3]; -$scope. A = ' 111 '; the$scope. B = ' 222 '; +$scope. A1 = {name: "Zhang San" }; A$scope. B1 = {age: "10" }; the$scope. IsArray = Angular.isarray ($scope. arr);//determines whether an array is +$scope. name1 = Angular.uppercase ($scope. Name);//turn into uppercase -$scope. EQ = angular.equals ($scope. A, $scope. b);//determine if two strings are equal $$scope. C1 = Angular.extend ($scope. B1, $scope. A1);//B1 Inheritance A1 $ Console.log ($scope. B1); -             varJSON = {"name": "Hello", "Age": "20" }; -$scope. JSON = Angular.tojson (JSON);//ToJson to convert a JSON object into a string the$scope. Json1 = Angular.tojson (JSON,true);//The second parameter indicates whether you want to format a -             varJsonstr = ' {' name ': ' Hello ', ' age ': ' 20 '} ';Wuyi$scope. Jsonobj = Angular.fromjson (JSONSTR);//Convert A string to an object the  -$scope. a2 = {name: "Zhang San" }; Wu$scope. B2 = {age: "10" }; -$scope. C2 = Angular.copy ($scope. A2, $scope. B2);//copy the A2 to B2,b2, the original value will be replaced. About  $             varJsonobj = {"name": "Hello", "Age": "20" }; -Angular.foreach (Jsonobj,function(Val, key) { - Console.log (val); -             }); A  +             varresult = []; theAngular.foreach (Jsonobj,function(Val, key) { -                  This. push (Val +key); $ }, result); the  the  the             //bind object As the context of a function the             varSelf = {name: "Zhang San" }; -             varf = angular.bind (self,function(age) { in$scope. info = This. Name + "is" +Age ; the Console.log ($scope. info); the             }); AboutF (30); the  the             //another way to spell bind the             varf = angular.bind (self,function(age) { +$scope. info = This. Name + "is" +Age ; - Console.log ($scope. info); the}, 30);Bayi f (); the  the         }); -         //You cannot define two Ng-app tags within a page, Bootstrap can dynamically initialize the model -         varApp1 = Angular.module ("MyApp1", []); the         varAPP2 = Angular.module ("MyApp2", []); theApp1.controller ("Firstcontroller",function($scope) { the$scope. Name = "Dynamic initialization of Model1"; the         }); -App2.controller ("Secondcontroller",function($scope) { the$scope. Name = "Dynamic initialization of Model2"; the         }); the         varDiv1 = document.getElementById ("Div1");94         varDiv2 = document.getElementById ("Div2"); theDocument.onclick =function () { theAngular.bootstrap (Div1, [' MyApp1 ')]); theAngular.bootstrap (Div2, [' myApp2 ')]);98         } About</script> -</body>101

Angularjs Practice Demo2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.