V
V
Vasily2014-02-05 07:16:58
JavaScript
Vasily, 2014-02-05 07:16:58

How can you load directives in an already running application in Angular?

Colleagues, I just can’t figure out how in Angular it is possible to load directives in an already running application (I use yepnope)?
Those. if use:

angular.module('app', []).directive('myDirective',[скипа скушала]

there are no problems - everything is clear, but for example in the case
var ngApp=angular.module('app', []);
yepnope({
            load: 'ng.js',
            complete: function() {
//глобальная функция myDirectiveFn с реализацией директивы загружается из ng.js
         ngApp.directive('myDirective', myDirectiveFn); 
}
});

will no longer work (as I understand it, due to the fact that angular.bootstrap has already worked). Question - how to overcome / what to do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-02-05
@VasiliyIsaichkin

Well, push it into the directive's factory function, and sort it out there.
In general, a somewhat strange approach. Polyfills do not need to be placed in directives. If the directive should work only under certain conditions, you can simply add a check to the link and if anything, just do nothing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question