AngularJS tip for dom ready
A tip on replacing ready from jquery, execute at end.
HTML
<div ng-controller="DomReadyCtrl">
Hello {{test}}
<a class="test" href="#" id="hellyeas" ng-click="test2($event)">my-text</a>
</div>
JavaScript
var app = angular.module('app', []);
app.controller('DomReadyCtrl', function($timeout, $scope){
$scope.test = "World";
/**
* added at the end of the execution stack
* could be used to replace jquery's ready
* there's already a DOM ready in the directive
* so this is only useful in CTRLs
*/
$timeout(function(){
alert('DOM ready');
});
alert('DOM not ready');
$scope.test2 = function(element){
var elem = angular.element(element.srcElement);
console.log(elem);
//innerHTML
alert(elem.id);
};
});
angular.bootstrap(document.body, ['app'])