Noobie confusion with params

Forgive my lameness in this question - but I’m super confused about how to access passed variables. Specifically - the sample app (sidemenu) provides a great template for what I’m trying to accomplish. Unfortunately, it lacks some specifics that would give me some insight into how things work.

.state('app.single', {
  url: "/playlists/{playlistId}",
  views: {
    'menuContent' :{
      templateUrl: "templates/playlist.html",
      controller: 'PlaylistCtrl'

In the above example - we’re being directed to the playlist.html view - which supposedly will display the detail of the item selected. But, alas, that code is missing - any attempt to address the {{playlistId}} field is unsuccessful. I’ve read several posts about angular and how it’s accomplished in, perhaps, a few different ways - but I can’t wrap my head around the correct syntax or what specifically is supposed to occur. I realize it’s a scoping issue - the variable isn’t available because it’s not in the current scope (even though it appears that it should be.

Any insight on how to properly code this would be helpful - it’d be even more helpful if the sample templates had that code already available. :smile:

Thank you,

Eric Brown

you have to inject $stateParams and you would have access to all routing variables via this object

Do you have an example of the proper syntax - I’ve attempted the following with no luck…

controller: (‘PlaylistCtrl’, [’$scope’, function($scope, $stateParams) {
$scope.theID = $stateParams.playlistId;

In your example you need to also inject $stateParams as a string:

.controller('PlaylistCtrl', ['$scope', '$stateParams', function($scope, $stateParams) { 


Thank you so very much!