javascript - Append a custom AngularJS directive on ng-click to a container HTML element -


I have one of the following problems: I have a complex custom command, which is used for information about input areas Woeful WS . I want to add this HTML code to ng-click using the current & lt; Button & gt; to wrap up. Please, take a look at the appendirective function, this is what a parent element should be directed to, which is called it.

The director looks like this:

  app.directive ('recursivefields', function copy: 'e', ​​replace: true, controller: "httpPostController" Template: '$ lp; div ng] $ {compiler: $ http} {return} {radius: {field:' = field ', model:' = model '}, restart: -repeat = "field in nested field. Nested field "& Gt; div ng-show =" {{Nestedfeld.ICCTA & amp;; Nestedfield.esennam}} "& gt; '+' & lt; p ng-show = {{nestedField.isRequired}} & Gt; {{Nestedfeld .name}} *: & lt; / p & gt; '+' & lt; p ng- show = {{nested field. SEREware}} & gt; {{Nestedfeld.name}}: & lt; / p & gt; '+' & lt; input type = "text" ng-model = "model [nested field.name]" ng-change = "Meet-receiptestiast text") '' 'class = "form-control" placeholder = "{{ParseClassName (nested field type}}} & gt;' + ' & # 39; & # 39; + + & lt; ; Div ng- show = "{{nestedField.isEnum}}" & gt; '+' & lt; p ng- {= NestedField.isRequired}} & gt; {{nestedfeld .name}} *:  me "recursivefield" directive  '+' & lt; / epicodyan-group & # 39; & # 39; + '& lt; / accordion & gt; + '& Lt; / div & gt;' + '& lt; / div & gt;', link: function (scope, element, etter) {console.log ("1"); if (scope.field.restResourceName ! = Null) {$ http.get (CONSTANTS.EXPLAIN_URL + "/" + scope.field.restResourceName). Seven ( Function (data, position) {scope.field.nestedFields = []; Data.content.resource.fields.forEach (function (field) {if (field.isEnum) {$ http.get (CONSTANTS.ENUMS_URL + area. $ Root.parseClassName (field.type) Success (work (data, position) {for field.enumValues ​​= []; (var data index.ontues.values ​​in index) {field.enumValues.push (data .content.values ​​[index])}}}}} scope.field.nestedFields.push (field);})}) scope.append direct = function () {var newDir = angular.element ('& lt ; Recursive field model = "createEntityResource" field = "field" & gt; & Lt; / recursive-fields & gt; '); $ (NewDir.contents ()) (scope) compilation; Warning ("full"); Basically, it looks like this:  & lt; Button & gt; After pressing   ,   

& lt; Div & gt; 2 must be nested direct, such as & lt; Div & gt; In other words, the instructions should be added to the parents of 1 (element 2 ) 3 .

Does anyone know the way to solve this issue?

Each useful answer is highly appreciated and evaluated. </ P> <p> Image Enter details here

You can do this:

  $ Scope.append Directive = function () {var recursive field = $ ("& lt; recursive-field /";); Recursive field Reuters ("Eparam", "AWW"); RecursiveFields.insertAfter (yourButton); $ RecursiveFields ($ scope); }   

and in html:

  & lt; Button ng-click = "append directive ()" & gt; Your button & lt; / Button & gt;   

Your administrator should compile $:

  myApp.controller ("myController", $ compile) {}    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -