0

I just want to check, whether the below mentioned situation is possible or not. Suppose, I have created a directive say "dummyDir", having restrict attribute as "EA" and link function just copying data from scope datasource to a variable, also, templateUrl being set to a url say "template.html". Now, from a controller say "callController", which is having a method say "callDirective", which is creating an element of type "dummy-dir" and appending this element to the body element. Now in the page, when this "callDirective" method is invoked/called, this "dummy-dir" element is present in the page, but the referencing templateUrl "template.html", is not present in the page.

So, whether I am doing some thing wrong because of which this template is not getting rendered or this is not possible from AngularJS?

Waiting for reply.

Ankur Mukherjee
  • 3,777
  • 5
  • 32
  • 39
  • Do you mean you want to insert directive dynamically? That is possible, but you need to [`$compile`](https://docs.angularjs.org/api/ng/service/$compile) the element that you have created so that it is recognized by Angular – PSWai Dec 21 '15 at 06:24
  • 1
    Reproduce your problem with some simple line of code and attach the code here. It will help everyone to understand you problem easily. You can use plunker or jsfiddle. – Partha Sarathi Ghosh Dec 21 '15 at 06:29
  • Check this answers: http://stackoverflow.com/questions/15279244/dynamically-add-directive-in-angularjs, http://jsfiddle.net/Chyngz/k9htwjae/ – Chyngyz Dec 21 '15 at 07:02

0 Answers0