A
A
AngelZeruel2015-03-21 05:07:37
JavaScript
AngelZeruel, 2015-03-21 05:07:37

How to process Angular code after receiving data via Ajax?

Good day to all! The following problem arose: there is a task to finalize the functionality of the comments system on the portal, and specifically, to add a spoiler element: Spoilerpan> itself. The spoiler filling (beautiful design) is loaded by the Angular directive. Comments on the pages are updated using an ajax request, the response comes in the form of an html code.
After adding the spoiler, it looks like plain text, but after reloading the entire page, it takes on the required form. From which I concluded that after making an ajax request, Angular does not process the page elements. In this regard, the question arose: is it possible to start the execution of the directive again without reloading the page? I would be grateful for an illustrative example.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Dedukhin, 2015-03-22
@Demetros

The response comes in the form of html code.

This is a vicious approach in the world of angular, get rid of this and only pass data in json.
In essence - look towards the $parse service, with its help you can process the received html with the angular parser, getting a function that can be called by passing the $scope object, and get the finished working markup.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question