@wave wrote:
Hi everyone,
I already read some threads but I do not realize what I am doing wrong.
I want to pass data with $state.go but it does not work.I have a "Category" site and want to navigate from a list entry to the "Cards" site and want to pass the category ID.
This is my Category site:
<ion-view title="Categories">
<ion-content overflow-scroll="true" padding="true" class="has-header">
<ion-list>
<ion-item ng-repeat="category in categories" ng-click="goToCards(category.id)">{{category.name}}</ion-item>
</ion-list>
</ion-content>
</ion-view>The routes:
.state('menu.categories', {
url: '/categories',
views: {
'side-menu21': {
templateUrl: 'templates/categories.html',
controller: 'categoriesCtrl'
}
}
})
.state('cards', {
url: '/cards/:catId',
templateUrl: 'templates/cards.html',
controller: 'cardsCtrl'
})The controllers:
.controller('categoriesCtrl', function($scope, Category, $state) {
$scope.categories = Category.query();
console.log($scope.categories);$scope.goToCards = function (id) {
console.log(id); //works
$state.go('cards', {catId: id});
}
}).controller('cardsCtrl', function($scope, $sce, LearnCard, Category, $ionicModal, $stateParams) {
console.log("stateParam: " + $stateParams.catId); }
When I click on a category list entry it only sends me to /cards. The console log shows me that the variable $stateParams.catID is undefined.
It would be great if someone would help me .
Posts: 1
Participants: 1