javascript - 引用子模块angularjs中的Controller

标签 javascript angularjs

我有两个模块A和B。 moduleA中有一个名为moduleAController的 Controller

如何在 html 中调用 moduleA 中的 Controller ?

下面是代码片段,但它不起作用。我只想直接在我的 html 中使用我的 Controller 。

var moduleA =angular.module("ModuleA");
var moduleB =angular.module("ModuleB",["moduleA"]);
var myapp=angular.module("MyApp",["moduleB"])

<html ng-app="myapp">
    <body ng-controler="moduleAController">

    </body>
</html>

最佳答案

此内容的重复:how to reference a controller inside a sub-module in angularjs

另一个解决方案在这里:

angular.module('myApp', []);
angular.module('myApp.myModule');

  angular.module('myApp.myModule')
       .constant('myModuleConst', {
  partialPath: 'path/to/partials/'
        });


  angular.module('myApp', [
       'myApp.nonsense', 
       'myApp.apparel', 
       'myApp.sounds', 
       'myApp.people']);

这里是引用文档:https://www.safaribooksonline.com/blog/2014/03/27/13-step-guide-angularjs-modularization/

关于javascript - 引用子模块angularjs中的Controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36930818/

相关文章:

c# - .NET 4.0 Web 浏览器控件和 msIsSiteMode javascript 错误

angularjs - 在 JSFiddle 上运行的简单 AngularJS

javascript - 从angularjs中的逗号分隔字符串列表拆分和映射数组

javascript - Angular JS 未捕获错误 : [$injector:modulerr] simple code

javascript - 将 CSV 文件上传到 dropbox.com 格式问题

javascript - 如何在Object.defineProperty值标志中访问这个变量?

javascript - 如何在列表中创建编辑功能?

javascript - context.clearRect(); 之后不断出现一个矩形

javascript - 获取错误 "Failed to instantiate module {0} due to:\n{1}"

javascript - 如何在指令 AngularJS 中包装 jQuery(默认)handsontable?