Code Download: Https://files.cnblogs.com/files/xiandedanteng/angularJSForeach.rar
Code:
<!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd "><HTMLNg-app= "Notesapp"> <Head> <title>New Document</title> <MetaCharSet= "Utf-8"> <Scriptsrc= "Angular1.4.6.min.js"></Script> </Head> <BodyNg-controller= "Mainctrl as CTRL"> <Divng-repeat= "Member in Ctrl.members">{{Member.id}}.name={{member.name}},age={{member.age}}<Div> </Body></HTML><Scripttype= "Text/javascript"><!--Angular.module ('Notesapp', []). Controller ('Mainctrl',[function(){ var Self= This; Self.members=[{ID:1, Name:'Andy', Age: -}, {ID:2, Name:'Bill', Age: +}, {ID:3, Name:'Cindy', Age: A}, {ID:4, Name:'Douglas', Age: at}, {ID:5, Name:'Einstein', Age: -}, ]; }]);// -</Script>
Effect:
Points:
The ng-repeat directive is one of the most powerful commands in Angularjs, which is able to iterate through an array, access the array's objects by key and value, and display them in HTML.
Angularjs example of a foreach loop