How to change templates for Angular 1.4 New Router based on dynamic params?

125 views Asked by At

I have the following $router configuration

$router.config ([
      { path: '/account/profile', components: {'main' : 'accountProfile' }},
      { path: '/campaigns/:type', components: {'main' : 'campaigns' }},
      { path: '/login', components: {'main' : 'login' }},
      { path: '/', redirectTo: '/home' }
  ]);

and I want to change template for campaigns based on their :type.

How can I do this using the new Angular Router?

1

There are 1 answers

0
Michael On

I think you could write your own TemplateMapping function - line 570 and return the templatename depending on the request params.