Answer the question
In order to leave comments, you need to log in
How to call a function after ng-repeat render?
Hello.
I am writing a single-page application, where by clicking on a link using ajax I get data from the server. The received data is output using ng-repeat. The problem is that I use scripts to highlight code in html and in order for this highlight to appear, you need to call a function that updates these styles.
For example, I have <pre class="java">code</pre>
$("pre.java").snippet("java") is called after the page is fully loaded, but if you try to call it after receiving an ajax response, then it is called after receiving, and not drawing on the page.
My directive:
app.directive("file", function() {
return {
restrict : "E",
scope : true,
controller : function($scope, $element) {
$scope.fileName = $scope.file.fileName;
$scope.fileContent = $scope.file.content;
},
link : function(scope, el, attr) {
scope.fileName = scope.fileName;
scope.fileContent = scope.fileContent;
},
template :
"<h3 class='title'>name: {{fileName}}</h3><pre class=\"java\">content: {{fileContent}}</pre>"
}
});
<pre>
, but after that the "fileContent" is not replaced. Perhaps someone faced a similar problem?
Answer the question
In order to leave comments, you need to log in
Everything is simple, we make syntax highlighting a directive and there are no problems, angular itself will destroy everything.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question