Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.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
Javascript 在路由中调用父控制器函数_Javascript_Angularjs - Fatal编程技术网

Javascript 在路由中调用父控制器函数

Javascript 在路由中调用父控制器函数,javascript,angularjs,Javascript,Angularjs,我正在使用ngRoute,我需要在我的route controller中调用父控制器函数。(我不使用$scope) index.html的一部分: <div class="col-lg-12" ng-controller="IndexController as index"> <div ng-view> </div> </div> 如何在route controller中调用hello()?首先,您需要在模块声明中添加一个空的

我正在使用ngRoute,我需要在我的route controller中调用父控制器函数。(我不使用$scope) index.html的一部分:

<div class="col-lg-12" ng-controller="IndexController as index">

    <div ng-view>
    </div>

</div>

如何在route controller中调用hello()?

首先,您需要在模块声明中添加一个空的依赖项数组

.module('project', [])
然后你需要调用你的函数。。像这样用按钮

<div class="col-lg-12" ng-controller="IndexController as index">

  <div ng-view>
    <button ng-click="index.hello()"></button>
  </div>

</div>


不明白您想要实现什么?我在“视图”文件夹中有index.html和模板。在某些路由中,我需要调用父控制器函数。我该怎么做?父控制器是IndexController,它应用于index.html中的div。该div包含ng view container.1.如果没有依赖项列表,ngRoute将无法工作2.我需要调用controller2内的函数。我需要从route controller调用函数
<div class="col-lg-12" ng-controller="IndexController as index">

  <div ng-view>
    <button ng-click="index.hello()"></button>
  </div>

</div>