I'm trying to save an array element in another variable using ng-click in ng-repeat, but when I click the element, it doesn't work.
This is my Code:
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body ng-controller="myCtrl">
<div ng-repeat="img in images">
<a ng-click="showing = img">{{img.descricao}}</a>
</div>
--------------------
Clicked element description is: {{showing.descricao}}
</body>
</html>
This is my javascript:
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
$scope.images = [
{
"id": 1,
"image": "http://placehold.it/300x300",
"ordem": 1,
"descricao": "Descricao 1"
},
{
"id": 2,
"image": "http://placehold.it/300x300",
"ordem": 2,
"descricao": "Descricao 2"
}
];
$scope.showing = {};
});
There is my complete code: http://jsbin.com/fuyuci/1/edit
Where I was wrong?