Answer the question
In order to leave comments, you need to log in
Angularjs: How to make a directive that is called after variable substitution?
Welcome all.
There is 1 controller, 1 directive and html.
The controller has $scope.variable.
There is such html
<div class="description" my-directive>
{{variable}}
</div>
link: function(scope,element){
var text = element.text();
console.log(text); // в text лежит {{variable}} а нужен сам текст этой переменной
}
Answer the question
In order to leave comments, you need to log in
angular.module('app')
.directive('myDirective', function () {
return function (scope, el, attr) {
scope.$watch('variable', function (text) {
console.log('$scope.variable = %s', text);
}
}
});
And in my opinion, you don’t need to betray or insert {{variable}} inside the directive at all.
jsfiddle.net/asrus2v7
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question