templateUrl context undefined when using route


This route fragment successfully matches and the template is loaded; however, “foo” resolves to an empty string and the context is undefined.

path: “/profile/linked/”,
id: “linked”,
templateUrl: “./profile/linked.html”,
options: {
context: {
foo: “bar”

Linked {{$route.url}} {{foo}} test
{{js 'return JSON.stringify(this.$route.context)'}}

results in:

Linked /profile/linked/ test


Can you create JS fiddle?


I have found the problem. My route is a tab route. If I put the context at the tab level, it works. At one level, this is fine. At another, a nice enhancement would be to merge any route specific options back up to the tab.

I think this change would do it, but am not super familiar with your source changes may be needed elsewhere due to side effects. I did utilize and extra option at the tab level to try to reduce the chace of side-effects. I have tested it locally on my use case. Line 6271:

if (sameParams) {
        if (options.route.route.tab) {
           // ehance options with those provided by the tab route
        	if(options.route.route.tab.options && options.route.route.options.childOptions) {
        		if(options.route.route.options.childOptions==="merge") {
        			options = Object.assign({},options,options.route.route.tab.options);
          	} else if(options.route.route.options.childOptions==="override") {
          		options = options.route.route.tab.options;
          return router.tabLoad(options.route.route.tab, options);
        return false;