AngularJS: $viewContentLoaded fired before partial view appears

This is related to angular digest cycle, it’s about how angular works underneath the hood, data binding etc. There are great tutorials explaining this. To solve your problem, use $timeout, it will make the code execute on the next cycle, whem the ng-if was already parsed: app.controller(‘LoginController’, function ($scope, $timeout) { $scope.$on(‘$viewContentLoaded’, function(event) { $timeout(function() … Read more

Calling a function when ng-repeat has finished

var module = angular.module(‘testApp’, []) .directive(‘onFinishRender’, function ($timeout) { return { restrict: ‘A’, link: function (scope, element, attr) { if (scope.$last === true) { $timeout(function () { scope.$emit(attr.onFinishRender); }); } } } }); Notice that I didn’t use .ready() but rather wrapped it in a $timeout. $timeout makes sure it’s executed when the ng-repeated elements … Read more