Can an Angular directive be added by Script?

0

What I'm trying to do is add the ng-checked directive on a <a> tag with JQuery because I use Bootstrap Material Design and it makes me not work said directive mentioned, since this CheckBox is redefined by some Script. When trying to do something like this:

<div class="switch">
    <label>
        <input type="checkbox" ng-checked="myRadio"> Active
    </label>
</div>

ng-checked="myRadio" appears as is in the html. Any suggestions?

    
asked by Samir Llorente 22.05.2018 в 08:19
source

2 answers

0

Apparently ng-checked does not exist for Angular, but for AngularJS. Which the code would be

<div class="switch">
    <label>
        <input type="checkbox" [checked]="myRadio"> Active
    </label>
</div>
    
answered by 22.05.2018 / 16:03
source
3

You can not do that, before generating the pure HTML code Angular.js compiles all the directives and templates. To make a modification of the directives or to add new templates to the object of the DOM it is necessary to use the $ compile library, take a look at it.

But to your answer, No, you can not put an angular directive by JQuery and it works.

    
answered by 22.05.2018 в 10:27