0

I am new to AngularJs and trying to load template on the basis of Id in angular route.

Here is my route :

angular.module('myApp', [])
  .state('template', {
       url:'/template/{id}',
       templateUrl: 'views/pages/template_main.html',
       controller: 'TemplateController',
       resolve: {
           loadMyDirectives:function($ocLazyLoad){
               return $ocLazyLoad.load(
               {
                   name:'myApp',
                   files:[
                     'scripts/directives/template1/template1.js',
                   ]
               })
            }
        }
    })

How can I achieve this?

if id==1 then it will load this: 'scripts/directives/template1/template1.js'

if id==2 then it will load this: 'scripts/directives/template1/template2.js'

How can I make conditions in route. Any suggestions?

Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
Rahul
  • 440
  • 7
  • 24
  • You talk about loading a different template, but give an example of `.js` file. Templates are HTML, not JS. What exactly is `template1.js` vs. `template2.js`? – New Dev Oct 15 '15 at 08:13
  • `template1.js `and `template2.js` are my directive inside this I am loading templates like `template1.html` and `template2.html` – Rahul Oct 15 '15 at 08:20

0 Answers0