In AngularJS you can use $onInit which is available on any AngularJS component: component lifecycle documentation . You can use it on a factories, controllers, services or modules. var app = angular.module('app',[]);
app('SomeController', function ($scope) {
//init state
$scope.myVariable = '';
//controller binding on view initialized
this.$onInit = function () {
$scope.myVariable = 'Hello World!';
}
}); $onInit() - Called on each controller after all the