[RESOLVIDO] angularjs duvida em ng-repeat
Olá galera!
Peguei o dia pra entender melhor esse tal de Angular.Js que a galera tanto fala.
Até q é bacaninha.
Só q 'travei' em uma duvida aqui..
Tenho a seguinte estrutura:
(Foque apenas no "images": )
[
{
"name": "Azurite",
"description": "Some gems have hidden qualities beyond their luster, beyond their shine... Azurite is one of those gems.",
"shine": 8,
"price": 110.50,
"rarity": 7,
"color": "#CCC",
"faces": 14,
"images": [
"images/gem-02.gif",
"images/gem-05.gif",
"images/gem-09.gif"
],
"reviews": []
},
{
"name": "Bloodstone",
"description": "Origin of the Bloodstone is unknown, hence its low value. It has a very high shine and 12 sides, however.",
"shine": 9,
"price": 22.90,
"rarity": 6,
"color": "#EEE",
"faces": 12,
"images": [
"images/gem-01.gif",
"images/gem-03.gif",
"images/gem-04.gif"
],
"reviews": []
},
{
"name": "Zircon",
"description": "Zircon is our most coveted and sought after gem. You will pay much to be the proud owner of this gorgeous and high shine gem.",
"shine": 70,
"price": 1100,
"rarity": 2,
"color": "#000",
"faces": 6,
"images": [
"images/gem-06.gif",
"images/gem-07.gif",
"images/gem-08.gif"
],
"reviews": []
}
]
E trecho em html :
<ul class="img-thumbnails clearfix">
<li class="small-image pull-left thumbnail" ng-repeat="(i, image) in product.images">
<img ng-click="gallery.setCurrent()" class="img-thumbnail" ng-src="{{image}}" />
</li>
</ul>
Minha duvida é:
Gostaria de passar o bendito do índice do array dentro da função ng-click.
Caso eu tento utilizar o tal do '$index'
<img ng-click="gallery.setCurrent({{$index}})" class="img-thumbnail" ng-src="{{image}}" />
Retorno esse erro:
>
Citar
angular.min.js:89 Error: [$parse:syntax] http://errors.angularjs.org/1.2.16/$parse/syntax?p0=NaNndex&p1=is%20unexpected%2C%20expecting%20%5B%3A%5D&p2=22&p3=gallery.setCurrent(%7B%7B%index%7D%7D)&p4=%index%7D%7D)&p4=%25index%7D%7D))
Engraçado q se eu fizer algo como:
<img ng-click="gallery.setCurrent()" id="{{$index}}" class="img-thumbnail" ng-src="{{image}}" />
Funciona sem erro de parser.
Já tentei passar por:
ng-repeat="(key, value) in myObj"
E utilizar o tal do filter porem continua a mesma.
Alguém consegue dar uma luz?
Aproveitando como se 'debbuga' no AngularJs?
Abraços.
Discussão (3)
Carregando comentários...