Sunday, April 30, 2017

$state.go and $state.params

In this Angular 1 paradigm of ui-router, $state.go as a method call typically contains at its signature where to redirect to as a first input and a JSON object of properties to map onto $state.params as a second input. At a $stateProvider wireup such as:

$stateProvider.state(whatever);

 
 

...whatever is going to need, as a JSON object, a property called params which will be a JSON object with properties for each of the $state.params to maps over and their default settings.

whatever = {
   name: 'foo.bar.baz.qux',
   url: '/this/that/theotherthing',
   params: { lucky: 13, everything: 42 },
   views: {
      'hogwash': {
         templateUrl: '/flapdoodle/malarkey.html'

 
 

I guess our $state.go might look like so:

$state.go('foo.bar.baz.qux', { lucky: 69, everything: 86 });

No comments:

Post a Comment