javascript - ng-click not firing with django/angular -
I have a template that is provided by Django, and I am trying to add some JS behavior with an angle . This is a pain
Here is the form ng_controller
is a detox reference variable set by my view
& lt; Form method = "POST" action = "#" ng-controller = "{{ng_controller}}" & gt; & Lt; A href = "#" ng-click = "search ('{% url' app name: search '%}')" square = "button" & gt; Search & lt; / A & gt; & Lt; A href = "#" ng-click = "add ()" square = "button" & gt; Add & lt; / A & gt; & Lt; Div class = "small -12 large-4 column content-box" & gt; & Lt; H4 & gt; Search results & lt; / H4 & gt; & Lt; Div class = "small-12.large4" id = "search_results" & gt; & Lt; / Div & gt;
Clicking on the search button works as expected, here is the function
search: (search_url) = & gt; Console.log "Searching ..." success = (results) - & gt; $ ("#Search_results"). ReplaceWith (result.data) Error = (Result) - & gt; Console.log "Error: # {results}" url = "# {search_url} /? # {Form_data}" @ $ http.get (url) Then (success, error)
The problem is that the result.data, which is correctly swapped in #search_results element, in ng-click
directives Which do not fire
& lt; A href = "#" ng-click = "foo ()" square = "button" & gt; Two fu & lt; / A & gt; & Lt; A href = "#" ng-click = "console.log ('foo');" Class = "button" & gt; Log foo & lt; / A & gt;
When those elements happen (after clicking on a search) they do nothing except jumping to the top of the page according to the anchor element. No error or anything (for the argument, foo ()
will only call console.log 'foo'
My suspicion is that Because these instructions are added later page loads, they are not actually wired by angular, so is it correct? And if this is the problem, how can I compile the instructions of this scheme, or else I I am looking at behavior, how can I get it? Understand that through java Using the Müller, there are problems adding the Dome, so I would be grateful for suggestions for dealing with the problem by making more replacement code with more idioms, as long as it can request AJAX at an AJAX endpoint.
As it turns out, I was right, and the results were not compiled. Clearly the results are compiling.
Success callback has been replaced with the following:
< Code> success = (results) = & gt; search_reference = $ (result.data) $ ("#search_results") replaceWith (se Arch_results) @ $ compiling (search_first) (@ $ radius)
I also injected the $ compiling provider into the controller class
Comments
Post a Comment