How to select a item of an array and show more info about it


#1

Hey! I’m new to Ionic and I’m having two small problems that I believe that should be easy to solve.
I’m creating a small movie app and I’ve already created a array with 3 movies and all their info.

Here’s the array of films created inside “watched page”.

.controller(‘watchedCtrl’, [’$scope’, ‘$stateParams’,

function ($scope, $stateParams) {
var movieslocal = [

{name:'Jurassic World',
descricao: 'Os donos de um parque temático de dinaussauros tentaram atrair turistas com uma emocionante nova exposição, mas um gigante mortífero foge e aterroriza toda a ilha.',
director:'Colin Trevorrow',
cast: 'Chris Pratt, Bryce Dallas',
genres: 'Action',
runtime: '2h17min',
rating: 'M/12',
release:'2015',
favorite: false,
watched: false},
{name:'Get Out',
director:'Colin Trevorrow',
cast: 'Chris Pratt, Bryce Dallas',
genres: 'Action',
runtime: '2h17min',
rating: 'M/12',
release:'2015',
favorite: false,
watched: false},
{name:'Guardians of the Galaxy 2',
director:'Colin Trevorrow',
cast: 'Chris Pratt, Bryce Dallas',
genres: 'Action',
runtime: '2h17min',
rating: 'M/12',
release:'2015',
favorite: false,
watched: false},

];

$scope.movies = movieslocal;

}])

and the list is shown in watched page like this:

The watched list only shows a list of the movies of that array.

My problem is how I can select a movie of the watched list and open a detail page of the movie with info in the array that I made.

Here’s how it looks the detail default page:

and also the code of detail default page: ( I did tried to use ng-repeat but it repeats 3 times the info because there are 3 movies in my array list)

Thank you so much!!


#2

you can use index of the array example: ng-click=“chosenIndex($index)”;

and in app.js

$scope.chosenIndex= function(index) {
//your logic here
};