首页 > 代码库 > AngularJS入门笔记01

AngularJS入门笔记01

AngularJS 表达式

使用ng-repeat 来循环数组
<div ng-app="" ng-init="names=[‘Jani‘,‘Hege‘,‘Kai‘]">
    <ul>
        <li ng-repeat="x in names">
            {{ x }}
        </li>
    </ul>
</div>

技术分享

 

<div ng-app="" ng-init="names=[
{name:‘Jani‘,country:‘Norway‘
},
{name:‘Hege‘,country:‘Sweden‘},
{name:‘Kai‘,country:‘Denmark‘}
];countrys=[
{name:‘1‘,country:‘a‘},
{name:‘2‘,country:‘b‘},
{name:‘3‘,country:‘c‘}
]">
    <p>循环对象:</p>
    <ul>
        <li ng-repeat="x in names">
            {{x.name + ‘,‘ + x.country}}
        </li>

        <li ng-repeat="y in countrys">
            {{y.name + ‘,‘ + y.country}}
        </li>
    </ul>
</div>

技术分享

 

AngularJS入门笔记01