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

时间:2021-03-19 12:08:33

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. 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?

但这也打破了它。你认为这和我使用的离子结构有关系吗?

Thanks for any help!

感谢任何帮助!

EDIT: Here's the working demo http://plnkr.co/edit/0eQZ0O?p=preview

编辑:这里是工作演示http://plnkr.co/edit/0eqz0o?

1 个解决方案

#1


3  

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.

如果你说的是组合模块。角的第一个参数。module是您要定义的模块的字符串名称,第二个参数是依赖性数组。

#1


3  

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.

如果你说的是组合模块。角的第一个参数。module是您要定义的模块的字符串名称,第二个参数是依赖性数组。