angularjs - Adding templateUrl dynamically while setting $routeProvider $ angular.config -


i angular newbie.i achieve following code...

 $routeprovider.when('/view', {templateurl: 'viewswitcher?pageid='+$rootsope.pageid+'&userid='+$rootsope..userid+'&token='+$rootscope.token, controller: ''}); 

viewswitcher servelet responses me html page per pageid,userid(saved in $rootscope) ......but $rootscope not available....thanks in advance!

you 1 thing here instead of store variables inside $rootscope use provider accessible inside config phase. create 1 mydata provider share data between different components of app.

code

//before using `mydataprovider` make sure has been injected dependency. $routeprovider.when('/view', {     templateurl: 'viewswitcher?pageid='+mydataprovider.pageid+'&userid='+ mydataprovider.userid+'&token='+ mydataprovider.token,     controller: 'myctrl' //<--here should controller }); 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -