Angular Directive not working for element created with document.createElement

    Angular directive with work for element created with document.createElement by this way
                                   
    var elem = angular.element( document.getElementById("<id of ng-app element>") );
    var scp = elem.scope();
    var inj = elem.injector();
    var $compile = inj.get("$compile");
    var btn = document.createElement("button");
    btn.setAttribute("class", "btn btn-primary");
    btn.innerHTML = "Play This Video";
    btn = $compile(btn)(scp);

    //add btn to the element wherever you want now directive will work for this
    5
    Average: 5 (1 vote)