Passing Parameter between Views

ionic is new to me and I have a problem.
I am trying to make a cooking app. I will have some lists (dinner, brakfast) which have sub sublists (chicken, burgers) and so on. Then they will end up in a recipe page.

My question is: How do I pass the parameters from the list to the recipe page?
How does the recepi page template know {{tilte}} and all other paramters I’ve put in the “controllers.js” file.

I am using “$ ionic start myApp sidemenu” and the playlist are doing a good job, but they do not end up in a “recipe” page.

If you could help I would really appreciate it


Make one service that hold the value of list item which was clicked.

And this service on the both page controller (list page and recipe page)

and make one method in list page controller that store clicked item data in to service variable.

which can be accessible on recipe page because we injected same service i recipe page controller.


 <ion-list class="margin-top-10 list" id="testList" ng-controller="recipeListController">
    <ion-item ng-repeat="recipe in recepies">
          <div class="item item-avatar col arrowDiv margin-0 item-text-wrap customer-item" ng-click="setRecipe(">
                        <h4>Recipe Name : <b> {{}} </b></h4>                     


App.controller("recipeListController", function($scope,recipeService) {

        //and your redirection stuff goes here.


  App.controller("recipePageController", function($scope,recipeService) {


App.service(‘recipeService’, function() {


<div ng-controller="recipePageController">

given code is just sample you can do this way.

Hi, and thank you for your help.
I tried it and I could not make et work :frowning:

What would it look like, if et was just one list and all the items on that list had a page.
So a list linking to a page and bringing parameters to the page.

Could you make that example? I am sorry that i dont get it.

Hey danielnn, jariwalabhavesh provides a common way for doing this. But if you mean the “bringing”, then $stateParams will be something you are looking for.

Normally, when you are defining your state in app.js files, you need to annouce the link. Now do the following (this is actually an official example):

.state('app.single', {
  url: "/playlists/:playlistId",  // here is what you annouce the params
  views: {
    'menuContent': {
      templateUrl: "templates/playlist.html",
      controller: 'PlaylistCtrl'

According to ui-router official stateParams doc, you can add as many params as you like. Just like:

.state('app.single', {
  url: "/playlists/:bigListId/{smallListId}/?from&to", 
  views: {
    'menuContent': {
      templateUrl: "templates/playlist.html",
      controller: 'PlaylistCtrl'

Next, in your “destination controller”, inject the $stateParams service, and access it just like normal object, it will parse all the params for you.

Hope this helps, feel free to ask if you have any further problems.

hi denielnn

sure i will explain it.

can you tell me the flow of your views?

then i can explain it better way.

windht has provided one of the way to send value to the next view.

Hi jariwalabhavesh,

I am making an app with list of allergy-friendly food.

I start with listing categories:

  • Fruit
  • Vegetable
    and so on…

If you click fruit I list ther different fruit and which one ar allergy-friendly (Green dot)

  • Apple

So far so good.

If you click Apple, I want a detail page for Apple with a title, text, an image and so on.

How do I Pass Parameter from Fruit to Fruit detail page?
The Category page is static html and that works fine for me

You can see the files here:

hi danielnn

here is working code


 <ion-view view-title="playlists">
      <ion-content ng-controller="PlaylistCtrl">
       V {{detailService.itemName}}


<ion-view view-title="Playlists">
      <ion-item ng-repeat="playlist in playlists" href="#/app/playlists/{{}}" ng-click="getDetail(playlist)">
       <i class="icon ion-{{}}"></i> 


angular.module('starter.controllers', [])

.service('detailService', function() {

.controller('AppCtrl', function($scope, $ionicModal, $timeout) {
  // Form data for the login modal
  $scope.loginData = {};

  // Create the login modal that we will use later
  $ionicModal.fromTemplateUrl('templates/login.html', {
    scope: $scope
  }).then(function(modal) {
    $scope.modal = modal;

  // Triggered in the login modal to close it
  $scope.closeLogin = function() {

  // Open the login modal
  $scope.login = function() {

  // Perform the login action when the user submits the login form
  $scope.doLogin = function() {
    console.log('Doing login', $scope.loginData);

    // Simulate a login delay. Remove this and replace with your login
    // code if using a login system
    $timeout(function() {
    }, 1000);

.controller('PlaylistsCtrl', function($scope,detailService) {
  $scope.playlists = [
    { title: 'Apple', id: 1, fm: "y"},
    { title: 'Banana', id: 2, fm: "n" },

.controller('PlaylistCtrl', function($scope,$stateParams,detailService) {
1 Like

Thank you very much. You really helped me out. :smile:

Hi again,
Okay, so now I made one static HTML list which links to different sublists.
It has 12 different controllers and it is not running tha great in the iOS Simulator.

My question is now? Is that just the simulator or is heavey because I made it that way?
What would be the correct way to Make All food -> Fruit -> Fruit Detail pages, If I were to make it with one template?

Help will be appreciated :sunny:

Hi danielnn

According to me there should be only three page.

  1. category list page.
  2. Subcategory list page.
  3. Detail page.

so no need to make separate page for each product so there should be only 3 controller and required service.

if i am getting wrong in your application functionality, then please tell me. I give you suggestion based on your 3rd post.

Hi jariwalabhavesh,
You helped me so much.

You are right about the 3 templates, but did you make that example or?
That is exactly how I would want it.

In the 3 post I just wanted a static list and then a dynamic list (fodmap_categories.html) with a detail page, but it seems that the static list is running very slow.

i had tested app on android it is working fine.

What actually problem you are facing with ios platform?

Did you make a version of the app with only three pages?

  1. category list page.
  2. Subcategory list page.
  3. Detail page.
    If you did, please make a branch on Github.
    I am not sure how to make i myself.

When I run the app with the 12 different lists, it run slow on iOS

I have busy schedule. so it will take some time.

You take all the time you need, I am just happy if you will help. Thank you :slight_smile:

This could be a bad idea, but you could use the angular $rootscope which will underly all pages.

Much simpler than passing stuff around in the routes

Okay, and how do I do that?$rootScope

Inject $rootScope exactly the same as you inject $scope in each controller and use it in the same way, the difference is variables added in $rootScope are visible in ALL controllers, also, I don’t believe you need to inject the $rootscope in other controllers if you are only adding to it in one controller due to scope hierarchies. ^^^ Read about it, it’s quite cool

Hi I am trying to send data from one view to another using $stateParams.Its working fine, but when my data contains “/” then it does not get the view.


In controller

in view

href="#/app/myview/:data" //here it is not getting the requesting view


internally it is treating #/app/myview/:data is treated as ** #/app/myview/:image/myimage.png**

because of “/” is $scope .data it is looking for different state that i have not configured.

I am completely stuck, any help would be very beneficial.

best regards,

Thank you very much. You really helped me out. :grinning: