I´m pretty noob in angular JS and I´m facing problem. the instruccion console.log($routeParams) show me a routeParams empty and I don´t know why. I created my proyect using the ionic yeoman generator.
this is inside my view (generates urls like this http://localhost:8100/#/app/tracking/50)
<p ng-repeat="item in items">
<a href="#/app/tracking/{{item .number}}" class="item item-icon-left">
<i class="icon ion-home"></i>
{{item .a}} - {{item .b}}
</a>
</p>
my router configuration in app.js
.state('app.tracking', {
url: "/tracking/:idItem",
data: {
requireLogin: true
},
views: {
'menuContent': {
templateUrl: "templates/tracking.html",
controller: 'TrackingCtrl'
}
}
})
This is my controller (I tried to acces in those ways)
.controller('TrackingCtrl', function($scope,$routeParams) {
console.log($routeParams);
console.log($routeParams.idItem);
console.log($routeParams["idItem"]);
})
I have ngRoute defined here int app.js
angular.module('starter', ['ionic','angular- md5','ngCordova','starter.controllers','ngRoute'])
And finally the reference to the bower component is the index
<script src="bower_components/angular-route/angular-route.js"></script>
Thanks in advance for your time
seems like your using angular ui-router
so you need to use $stateParams
instead of $routeParams
.