Answer the question
In order to leave comments, you need to log in
How to get text inside AngularJS directive tag?
Hello.
There is no way to get the text inside the directive tag.
I have html code
<div data-keditor>Lorem ipsum dolor sit amet...</div>
myapp.directive("keditor", function () {
return {
template: '<textarea rows="10" cols="30" style="height:200px;" ></textarea>',
replace: true,
scope: {},
link: function(scope, element, attributes) {
console.log("где-то здесь нужно вернуть текст 'Lorem ipsum dolor sit amet...'");
// замена происходит правильно
element.text("test");
}
}
});
Answer the question
In order to leave comments, you need to log in
why not do that?
myapp.directive("keditor", function () {
return {
template: function (el, attr) {
return '<textarea rows="10" cols="30" style="height:200px;" >'+el.text()+'</textarea>';
},
replace: true,
scope: {},
link: function(scope, element, attributes) {
console.log("где-то здесь нужно вернуть текст 'Lorem ipsum dolor sit amet...'");
// замена происходит правильно
element.text("test");
}
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question