I've started developing a simple application :
in the first view I'm retreiving all the games, and the other view i'm retreivig the game details according to the game id.
I didn't link the two pages yet.
this is what i'm facing as problem. i'm confused ! should I use ion-view ?? or I should use a normal page
for each view I have a controller which look almost like :
.controller('tomorrowmatches', function($scope, $http) {
$http.get("http://www.myappbackend/ofc/matches?date=2015-05-03")
.success(function (response) {
$scope.matches = response;
}
});
})
and how to pass data from conroller to another, in my example I wanna pass the game.id as shwon on the screenshot.
if you need more details just let me know. I just need someone to make things clear for me, and if there is an example it would be fantastic.
First of all you need the ion view as a container for your views/templates..
then on your app.js you need to configure your routing..
Note: Make sure that all dependencies for ionic are included on your folder and called on your index.html..
Hope this helps :)
To pass data to another view you can use the $state and $stateParams services.
Example
Controller 1 (sends the data)
Controller 2 (gets the data)
app.js
As you can see in the state
yourState
I assigned anid
as a parameter. This parameter will be checked if exists byYourCtrl
, if it exists assign to scope and then do whatever you want with it.Remember to set the parameter options in your app.js route configuration.
Check the ui-router docs for more info on this. You have more ways to send data.