My trying to create dynamically an element and during the creation attach an ng-click
to it. I know I need to compile
that element, only it isn't working. I read here but not able to make it work with my element.
function compile(element){
var el = angular.element(element);
$scope = el.scope();
$injector = el.injector();
$injector.invoke(function($compile){
$compile(el)($scope)
})
}
function foo(){
var element = angular.element("<"+element+" ng-click='x()' placeholder='input'>");
compile(element);
}