Answer the question
In order to leave comments, you need to log in
How to access a dynamically created element in angular?
How to get an element with a directive that was created dynamically?
<div test ></div> // динамически создан
App.directive("test", function(){
........
element. ....... // так не работает
})
Answer the question
In order to leave comments, you need to log in
Uh ... turn on the telepath mode.
Let's say you have the following code:
angular.module('app', [])
.directive('foo', function () {
return function (scope, el, attr) {
el.append('<div bar></div>');
}
}
.directive('bar', function () {
return function (scope, el, attr) {
console.log('init bar directive');
}
});
<div ng-app="app">
<div foo></div>
</div>
angular.directive('foo', function ($compile) {
return function (scope, el, attr) {
var child = $compile('<div bar></div>')(scope);
el.append(child);
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question