ANGULARJS Study 2

Source: Internet
Author: User

ANGULARJS Study 2

1.filter Filtration

1 @{2Layout =NULL;3 }4 5<! DOCTYPE html>6 789<meta name="Viewport"Content="Width=device-width"/>Ten<script src="~/scripts/angular.js"></script> One<title>Test3</title> A -<body> -<div ng-app=""> the<div> Input: <input type="text"Ng-model="name"/></div> -<p> Results:{{name|uppercase}}</p> -</div> -</body> +

2.filter Logarithmic Group filtering

1 @{2Layout =NULL;3 }4 5<! DOCTYPE html>6 789<meta name="Viewport"Content="Width=device-width"/>Ten<script src="~/scripts/angular.js"></script> One<title>Test4</title> A -<body> -<div ng-app=""ng-init="family=[ the{Name:'FATDU', Age: +}, -{Name:'Smartpan', Age: the}, -{Name:'Olddu', Age: -}, -{Name:'Ando', Age: -} +]"> -<p> Filter: <input type="text"Ng-model="name"/></p> +<ul style="List-style-type:none"> A<li> name, age </li> at<li ng-repeat="x in family | Filter:name"> -{{x.name+','+X.age}} -</li> -</ul> -</div> -</body> in

3.ng-repete

1 @{2Layout =NULL;3 }4 5<! DOCTYPE html>6 789<meta name="Viewport"Content="Width=device-width"/>Ten<title>Test1</title> One<script src="~/scripts/angular.js"></script> A -<body> -<div ng-app=""ng-init="friends=[ the{Name:'Du', Age: -}, -{Name:'Ando', Age: -}, -{Name:'Pan', Age: the}  ]"> -<table> +<tr ng-repeat="x in Friends"> -<td>{{'Name:'+x.name+', Age:'+x.age}}</td> +</tr> A</table> at</div> -</body> -

4. How do I display data in a declarative template?  

1 @{2Layout =NULL;3 }4 5<! DOCTYPE html>6 789<meta name="Viewport"Content="Width=device-width"/>Ten<script src="~/scripts/angular.js"></script> One<title>Test5</title> A  -<script type="Text/javascript"> -             varDu = { theName"Ando", -Gender"male", -Age - -             }; +             //the module (dumodule) and instruction (Dudir) here correspond to the content in the following HTML.  -Angular.module ("Dumodule", []). Directive ('Dudir', function () { +                 return { ARestrict"E",//element atTemplate"<div></div>", -Replacetrue,//You can replace the instruction block (DU-DIR) in the HTML with the template. - link:function (scope, element, Attrs) { -                         //the defined value can be obtained by Attrs.data.  - Debugger; -                         varDu = eval (attrs.data);//If you do not have eval, you will only get the string "Window.du", and the name below will be undefined. inElement.append ("<div> Name:"+ Du.name +"</div>"). Append ("<div> Surname:"+ Du.gender +"</div>"). Append ("<div> Age:"+ Du.age +"</div>");  -                     } to                 }; +             }); -</script> the *  $<!--here the module and instruction correspond to the above--Panax Notoginseng<body ng-app="Dumodule"> -<du-dir Data="Window.du"></du-dir> the</body> +

ANGULARJS Study 2

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.