1
Good morning Gentlemen.,
How can I pass data from an item that has been selected within an ng-repeat list to another view?
Here is an excerpt from the first view:
<div ng-repeat="jogador in dadosjogador | filter:{xid:equipe.jogador}" >
<div class="item-avatar item-button-right">
<img src="img/user1.jpg">
<h2>{{jogador.nome}}</h2>
<form action="voto.html" class="urna">
<input type="submit" value="Votar" />
</form>
</div>
</div>
Below is an excerpt from the code of the second view:
<body ng-app="starter" ng-controller="equipecontrol">
<ion-header-bar class="bar-calm" align-title="center">
<button class="button button-icon icon ion-ios-arrow-back ng" ng-click="goback()"></button>
<h1 class="title">{{jogador.nome}}</h1>
<button class="button button-icon icon ion-navicon" ></button>
</ion-header-bar>
</body>
In this second view I used {{jogador.nome}}
but the player’s name is not displayed.
I’ve tried using a variable $rootScope._nomejogador
, I declared the same in the equipecontrol controller, which is common the two views, but also do not know how to do: $rootScope._nomejogador = {{jogador.nome}}
the moment the item is selected and calls the other view.
Would anyone have an idea how I can resolve this issue
interesting the question of the vote button, but my need is to pass information from the ng-repeat item to the other view. You’d have an idea how to do that?
– Ita
@Ita The example above demonstrates exactly this process - information sharing between a collection under iteration to another view. What would be your specific doubt that is not covered by the example?
– OnoSendai
I tried to implement this way that you guided but did not succeed. I put the collections in a Service and in the controller declared a $Scope variable receiving the service, I remember that I have only one controller for both views, however when I try to list the collection, even in the first view, nothing is presented. Previously the player data collection was declared in the controller as $rootScope, now that I declared it as this within the service and it is no longer listed.
– Ita