[SOLVED] Set StateParams in ng-href

Hi all!

Does anybody know how i can send an id over an link?

Template:

<ion-item nav-clear menu-close ng-href="#/app/home/{{profile.id}}" ng-repeat="profile in profiles" class="item">

Config:

.state('app.home', {
  url: '/home/:id',
  cache: false,
  views: {
    'appContent': {
      templateUrl: 'templates/app/home.html',
      controller: 'appHomeCtrl',
    },
  },
})

Controller:

if ($stateParams.id) {
  alert($stateParams.id);
}

you do not need to put in the absolute path:

try using only ng-href="/home/{{…}}"

or use ui-sref directive of the uiRouter

ui-sref="app.home({ id: profile.id })"
2 Likes

Thank you, @bengtler!