llerdal
llerdal

Reputation: 387

Call angularJS function on page load from JavaScript

I am very New to AngularJS and I have an web Application that calls an ng-click when a button is clicked. I would like to add code to call this function on page load.

enter image description here

This is the where the function is called in the code. Is there anyway to do this?

Upvotes: 0

Views: 78

Answers (2)

inubs
inubs

Reputation: 519

When element is loaded you can fire ng-init

<div ng-init="zoom.fit()">
  some code
</div>

ng-init documentation

Upvotes: 1

Drone
Drone

Reputation: 1134

Use this in your controller

$scope.$on('$viewContentLoaded', function() {
  $scope.zoo.fit();
});

Upvotes: 0

Related Questions