简体   繁体   English

从JavaScript加载页面时调用angularJS函数

[英]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. 我是AngularJS的新手,我有一个Web应用程序,当单击按钮时会调用ng-click。 I would like to add code to call this function on page load. 我想添加代码以在页面加载时调用此函数。

在此处输入图片说明

This is the where the function is called in the code. 这是在代码中调用函数的位置。 Is there anyway to do this? 反正有这样做吗?

When element is loaded you can fire ng-init 加载元素后,您可以触发ng-init

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

ng-init documentation ng-init文档

Use this in your controller 在控制器中使用它

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM