I have following controller which works just fine for dynamic compilations of new DOM elements after some ajax actions:
angular.module('cms').controller('CompileHtmlCtrl', [
'$scope', '$compile',
function ($scope, $compile) {
$scope.compileHtml = function (id) {
$compile("#"+id)($scope);
};
}
]);
Problem comes when I was trying to change URL in reaction on ajax action because if I call pushState
anywhere (after or before compilation), angular will allways change the URL back.
window.history.pushState({}, '', url);
Is possible to prevent angular doing that?
Resolved using $digest
.
$compile("#"+id)($scope);
$scope.$digest();
Then I have found mayby better solution turning off angular URL manipulation Turn off URL manipulation in AngularJS.