javascript - Angular Controller 名称在模块之间发生冲突

标签 javascript angularjs web-applications controller typescript

我有两个模块(A 和 B),其 Controller 具有相同名称。当我将 Controller 导入模块 C 时,具有相同名称的 Controller 会相互覆盖。

有什么方法可以避免这种情况呢?我的 Controller 的“module.controller”类型的命名约定?

谢谢!

更新

这是一个代码示例:

module('a',[]).controller("con");
module('b',[]).controller("con");

module('c', ['a','b']) // controller from a overrides controller from b

最佳答案

What is the way to avoid this?

在 Controller 名称前添加诸如 axs 之类的前缀,例如axsCon

注意:这是 Angular1 设计的问题。都是全局性的。事实上,指令都是全局的,它们的名称也应该有前缀。

关于javascript - Angular Controller 名称在模块之间发生冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36462650/

相关文章:

java - 0 在工作区中引用我知道正在调用的方法

python - 使用 http 请求更新谷歌电子表格

javascript - AngularJS:在没有范围的字符串中编译 Angular 代码

angularjs - 循环到 angularjs 中的数字

web-applications - 内部站点搜索

Javascript - 将字符串附加到包含点字符的对象的键

angularjs - Laravel 和 AngularJS View 结构

javascript - 如何纠正从 jsFiddle 到 HTML 的 no wrap(head) JavaScript 以使其正常工作

javascript - 在 Angular :how to get "selected" option by ng-selected

javascript - 无法在子组件中访问 c​​lass.contextType