angular ui router - How to access state params (ui-sref) without including them in URL propery of state in angularjs -


this question might similar different requirements. not able make comment (required 50 points) replicating question.

i want access parameters sent ui-sref in template inside controller without mentioning them in state url .

something using link below transitioning state home foo , bar parameters:

<a ui-sref="home({foo: 'fooval', bar: 'barval'})">go home state foo , bar parameters </a> 

receiving foo , bar values in controller:

state('home', {       url: '/:foo',       views: {         '***whatisthis***': {           templateurl: 'home.html',           controller: 'mainrootctrl'             },      app.controller('somecontroller', function($scope, $stateparam) {       //..       var foo = $stateparam.foo; //getting fooval       var bar = $stateparam.bar; //getting barval       //..     });      

i undefined $stateparam in controller.

could me understand how done? want bar without adding url

if of params not supposed show in url, need combine url , params:

.state('home', {     url: '/:foo',     params: {         foo: 'default value of foo',         bar: 'default value of bar'     },     ... }) 

and use $stateparams properly:

.controller('somecontroller', ['$scope', '$stateparams', function ($scope, $stateparams) {     // ... (use $stateparams) }]) 

(see documentation).


and, if you're still stuck, please take @ working codepen demo.


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -