After doing some search I haven\'t found much information in this bad practice. Let\'s say I have a controller that behaves like that (I know it should have been a directive and
Based on Mohammad Shahrouri's comment above, I had to inject the $compile
dependency in the controller and I had to add $compile(input)($scope);
at the end:
angular.module('app').controller('test', ['$scope','$compile',
function($scope, $compile) {
$scope.addElement = function() {
var input = document.createElement('input');
input.type = "text";
//contains directive
input.setAttribute("autosize","autosize");
input.setAttribute("ng-model","dummy");
//[ append code ]
input.focus();
$compile(input)($scope);
}
}
]);