1

I'm trying to split my directives from being all in one file to dynamically calling directives when I need them. To do this I'm using couchpotato which can be found here: LINK

I took a look at the example from the sample project found here but my attempt does not seem to work. No errors are reported either.

This is my PLUNKR trying to use two directives one which just alerts a message and the other which just adds css to the element.

Malcr001
  • 8,179
  • 9
  • 44
  • 57
  • If you're still trying to avoid routing, then each page needs to load angular, configure one or more modules, and bootstrap the page. At that point, there's really no point in lazy loading. You can use regular angular/requirejs techniques to configure your modules and components. The requirejs module files will be cached by the browser for as long as your server tells them to be cached. I'm not clear on why you're trying to lazy load when you're going to reload angular on every page (since you're not using routing and templates)... – laurelnaiad Jul 09 '13 at 23:34
  • I don't want to download all directives when only one directive may be only needed. That is my main point. Setting a bunch of directives to load in the config is also not a great way to do it. I know you really don't like the way I'm doing it however nothing is wrong with using angular for multi page apps. – Malcr001 Jul 11 '13 at 21:17
  • It's all good... no worries. I'm just recommending you use regular requirejs/angular techniques and not couchPotato since you're not doing routing. Your component files will be cached for as long as your server-supplied header sets them to be. – laurelnaiad Jul 18 '13 at 21:41
  • Caching point aside it makes sense for me to split my directives up for the sake of organisation and better management otherwise directives.js is only going to get bigger and bigger. How do you propose I do this bearing in mind that requirejs is being used here. Injecting a directive into angular after the app has been bootstrapped is my main problem I believe. This is what I was using couchpotato for however as my original question states my attempt at using couchpotato to do this simply does not work. – Malcr001 Jul 18 '13 at 21:58

0 Answers0