Is there any sensible simple example of this?
There is a bunch of JS and jQuery code that needs to be run only after AngularJS has done all its job. There is no time to redesign and implement the existing JS/jQuery working code in the Angular "way".
Run JS code after Angular is done. As simple as that. Possible?
Fixing my question: the code should run after initial page load, i.e. - after AngularJS has done all initial DOM manipulations.
Thanks!
2 Answers 2
You can use a combination of checking ...
$scope.$on('$viewContentLoaded', function(){
// view content is loaded..
});
and loading after bootstrap with a lazy loader such as ocLazyLoad
ex.
$ocLazyLoad.load(['/foo.js']).then(function(){
// use foo.js
});
Comments
Place this at the end of your html. it is equivalent of jquery document ready and executes after it.
<script>
angular.element(document).ready(function () {
//place your javascript and jquery code here to execute after
//angular controller has done it's work
alert('angular work is done. run javascript');
});
</script>
myApp.directive('onAngLoad', function($timeout) { return { restrict: 'A', link: function(scope, element, attrs) { $timeout (function () { // regular JS and jQuery here }, 1000); } }; });