2

Used this link to update my accordion template. Now I need to replace another UI bootstrap template for carousel. Is there a way that I can chain the decorator functions together or should it be done another way? Also, what if I need to have various versions of the carousel? What then?

What i have right now obviously isn't working:

.config(['$provide', Decorate])

function Decorate($provide) {
  $provide.decorator('accordionGroupDirective', function($delegate) {
    var directive = $delegate[0];

    directive.templateUrl = '/modules/projects/views/admin/templates/accordian.html';

    return $delegate;
  })
  .decorator('carousel', function($delegate) {
    var directive = $delegate[0];

    directive.templateUrl = '/modules/projects/views/admin/templates/carousel.html';

    return $delegate;
  })

}
Community
  • 1
  • 1
Justin Young
  • 2,393
  • 3
  • 36
  • 62

1 Answers1

0

Whenever you wanted to decorate any of the existing component from configuration phase of angular, you need to append the Component type to its name, like here you are going to decorate Directive, so you need to provider the name to decorator as carouselDirective instead of just carousel.

Code

.decorator('carouselDirective', function($delegate) {
    var directive = $delegate[0];

    directive.templateUrl = '/modules/projects/views/admin/templates/carousel.html';

    return $delegate;
})
Pankaj Parkar
  • 134,766
  • 23
  • 234
  • 299