angular.js - angularjs中使用ng-repeat循环后渲染出的DOM如何绑定数据?
淡淡烟草味
淡淡烟草味 2017-05-15 16:54:57
0
1
464
app.controller("mainController",function($scope){
    $scope.taskNames = ['a','b','c','d'];
    $scope.showName = function(name){
        console.log(name);
    }
})



HTML:部分
<p ng-controller="mainController">
    <ul>
        <li ng-repeat='taskName in taskNames' ng-click='showName({{taskName}})'> //这里我是想获取taskName的值的,但是获取不到,那么我能通过什么方式能获取到taskName上的值呢?
    </ul>
</p>
淡淡烟草味
淡淡烟草味

reply all(1)
習慣沉默

Directly showName(taskName) No need to bind anymore, it will be automatically parsed in ng-click

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template