简体   繁体   English

如何在Angular.js中合并两个控制器?

[英]How to combine two controllers in Angular.js?

I'm new to Angular, and I've got two seperate controllers that work fine separately, but when I try to combine them in the same page, on of them gets broken. 我是Angular的新手,我有两个单独的控制器可以单独正常工作,但是当我尝试将它们合并到同一页面中时,其中一个就坏了。 You can check them out here: 您可以在此处查看它们:

http://plnkr.co/edit/RUKCNUsiLLHja5BCsOXi?p=preview http://plnkr.co/edit/RUKCNUsiLLHja5BCsOXi?p=preview

http://plnkr.co/edit/UkGEaquNkXGfUgbuYBki?p=preview http://plnkr.co/edit/UkGEaquNkXGfUgbuYBki?p=preview

I've tried to combine both controllers like this: 我试图像这样组合两个控制器:

var app = angular.module('App', ['audioPlayer'], [ngSocial]);

But that breaks it as well. 但这也打破了它。 Do you think it has anything to do with the Ionic framework I'm using? 您是否认为这与我使用的Ionic框架有关?

Thanks for any help! 谢谢你的帮助!

EDIT: Here's the working demo http://plnkr.co/edit/0eQZ0O?p=preview 编辑:这是工作示例http://plnkr.co/edit/0eQZ0O?p=preview

Could you show the third example where it actually breaks. 您能否显示第三个示例实际中断的地方。 It looks like you should have: 看来您应该具备:

var app = angular.module('App', ['audioPlayer', 'ngSocial']);

If you're actually talking about combining modules. 如果您实际上是在谈论组合模块。 The first parameter to angular.module is the string name of the module you're defining, the second parameter is the array of dependencies. angular.module的第一个参数是您要定义的模块的字符串名称,第二个参数是依赖项数组。

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

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