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
Post a Comment