angularjs中的数组过滤器不起作用

时间:2015-05-21 05:28:33

标签: arrays angularjs filter

我试图只用角度显示我的数组元素的名称,但它不起作用,你能帮忙吗?这是代码:



<div ng-app="myapp" ng-controller="MyController" ng-model="myData">
    <ul>
        <li ng-repeat="item in myData.items"
               ng-click="myData.doClick(item, $event)">{{myData.item.name}}</li>
    </ul>
</div>

<script>
    angular.module("myapp", [])
            .controller("MyController", function($scope) {
                $scope.myData = {};
                $scope.myData.items = [{ name: "1"}, { name: "2"}, { name : "3"} ];

                $scope.myData.doClick = function(item, event) {
                    alert("clicked: " + item.name + " @ " + event.clientX + ": " + event.clientY);
                }


            } );
</script>  
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:3)

你只需要写下面的表达式 {{item.name}}