1

I am calling state on the ui-sref with limited success.

I am able to get back the person.id value. I am seeking to get back all values off of the key object.

   $stateProvider.state('itinerary', {
        url: '/itinerary',
        views: {
            "main": {
                controller: 'ItineraryCtrl',
                templateUrl: 'src/app/itinerary/itinerary.tpl.html'
            },
            resolve: {
                 dates: ['$stateParams', function($stateParams){
                console.log('name',$stateParams);
                return $stateParams.dates;
                }]
            }
        },
        data: {
            pageTitle: 'Itinerary'
        }
    });

is there a way to get all properties of the object to pass?

Here is the html tag that I am using

<td><a ui-sref="itinerary.name({name:person.id, details:person.dates})">{{person.name}}</a></td>
2
  • what to you mean by key object? are you looking to get the whole person object? Commented Aug 29, 2015 at 0:21
  • That was my goal. I apologize, i meant key value. I was returning a value for person.id. I could change person.id to any other value, person.dates or person.status. However, I could only get on specific value at a time Commented Aug 30, 2015 at 3:26

1 Answer 1

2

Params should be defined on the URL, so you get consitent behaviour if loading state from ui-sref, $state.go or by typing in the URL. In this case params have to be strings.

$stateProvider.state('itinerary', {
    url: '/itinerary/:name/:details',
    // ... 
});

You can pass objects to a state, but this won't work when loading state from URL. To do this, define your params in the params property:

$stateProvider.state('itinerary', {
    url: '/itinerary/:name',  // name from URL
    params: {
         details: null        // details object
    },
    // ... 
});
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.