I am trying to display only the names of my array elements with angular but it is not working, can you please help? here is the code:
<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>
{{myData.item.name}}instead of this you have to write this{{item.name}}