Мне нужно добавить директиву элемента "<my-directive></my-directive>"
, но при попытке скомпилировать директиву в другом контроллере, он возвращает объект только не в виде html.
Рассмотрим добавленное ниже как пример директивы
export default class myDirective{
constructor($document, $window, $rootScope,$timeout,$compile) {
this.restrict = 'E';
this.scope = {
requrl: '@'
};
this.templateUrl = 'path.html';
this.controller = myController;
this.controllerAs = '$ctrl';
this.bindToController = true;
this.transclude = true;
}
link(scope, element, attrs) {}
static myDirectiveFactory($document, $window, $rootScope, reqs, $timeout, $compile) {
myDirective.instance = new myDirective($document, $window, $rootScope, reqs, $timeout, $compile);
return myDirective.instance;
}
}
Код компиляции добавлен ниже
this.$compile('<my-directive></my-directive>')(this.$scope)[0])