Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 使用angular js从Document.ready调用函数_Angularjs - Fatal编程技术网

Angularjs 使用angular js从Document.ready调用函数

Angularjs 使用angular js从Document.ready调用函数,angularjs,Angularjs,我有一个main.html,它在encMain的控制器范围内。这个页面有几个按钮 main.html -------- <div ng-app="enc" ng-controller="encMain"> <input type="button" value="Click A" ng-click="A()" ></> <input type="button" value="Click B" ng-click="B()"></> <

我有一个main.html,它在encMain的控制器范围内。这个页面有几个按钮

main.html
--------
<div ng-app="enc" ng-controller="encMain">
<input type="button" value="Click A" ng-click="A()" ></>
<input type="button" value="Click B" ng-click="B()"></>
<input type="button" value="Click C" ng-click="B()"></> 
</div>


main.js
-----
var app = angular.module('enc', []);
app.controller('encMain', function ($scope) {

$scope.A = function() { alert('A function is invoked') }

$scope.B = function() { alert('B function is invoked') }

$scope.C = function() { alert('C function is invokedl') }



}
案例1。假设我有一个页面“Y”,我将调用下面的“updateA”函数。 我在调用函数时没有任何问题。但是,一旦在内部调用该函数 我需要调用encMain范围内的'A'函数。问题是我不知道如何从document.ready调用函数“A”,或者如何获得作用域的引用,以及如何给出调用函数A的引用

案例2。在DOM准备就绪后调用UpdateBandC(),该DOM在内部需要调用 encMain范围内的B'和C'功能。问题是我不知道怎么打电话 当文档准备就绪时,功能B和C的参考,或者如何获得范围的参考,以及如何 给出调用函数a和B的引用

谢谢。请忽略输入错误。
请帮忙

谢谢。成功了。但我想知道是否有更好的方法
$(document).ready(function() {

  --- updateA function will be invoked from some X page. 
  window.updateA = function(){
   $scope.A - function A to be called here. this is inside in the scope of encMain.
 }

 function UpdateBandC(){
   $scope.B - function B to be called here. this is inside in the scope of encMain 
   $scope.C - function C to be called here. this is inside in the scope of encMain.
  } 

 UpdateBandC() - Call to the above function UpdateBandC.
}