Angular——迭代器ng-repeat

来源:互联网 发布:数据库建模 编辑:程序博客网 时间:2024/06/06 09:24

ng-repeat


  • html
<div ng-repeat="answer in answers">    <ons-button class="button button--large--cta" ng-click="pushPage2($index+1)">            {{answer}}    </ons-button>    <br /></div>
  • js
module.controller('Page2Controller', function($scope) {    $scope.answers=["aa","bb","cc"];    $scope.pushPage2 = function(index) {        alert(index);    }});
  • result(点击bb)

这里写图片描述
这里写图片描述

1 0