我开始使用Angular,并且我不明白何时使用或不使用[]
时声明(如果它是这样的)模块和控制器。Angular:何时在模块和控制器中使用“[]”
到目前为止,我明白了:
angular.module('app.prof', []).config(config);
意味着我声明模块prof
而angular.module('app.prof').config(config);
意味着我呼叫它。
但我总是最终在控制器中有[]
,而不是在模块中,当我有两个控制器时,我不知道该怎么做了。
我只是想了解角:(
编辑:添加更多的细节
在我的角度项目中,我使用的保险丝主题,一个叫约曼(如果我深知)的事情,所以我从来不写。<script>
标签的任何地方我自己
例如,我有这个模块:
angular
.module('app.prof')
.config(config);
与此控制器:
angular
.module('app.prof', [])
.controller('ProfController', ProfController);
我的模块和控制器总是以这种方式声明,但有时我得到像“模块未声明”或“控制器未声明”的错误;使我最终随机地在模块或控制器中放置括号,直到它工作。
编辑2:
这里是我的主要模块:
angular
.module('fuse', ['app.prof']);
我的教授模块:
angular
.module('app.prof')
.config(config);
,我的教授控制器:
angular
.module('app.prof', [])
.controller('ProfController', ProfController);
这样,整个事情工作正常。但是当我做:
angular
.module('app.prof', [])
.config(config);
和
angular
.module('app.prof')
.controller('ProfController', ProfController);
我得到:
哎呀小打字错误 – Orsu
如果您给出与您的示例相对应的特定错误,这将有所帮助。因此,不要说“有时候我会得到这样或那样的错误”,请说“用这个示例代码我看到了这个特定的错误”。你会更有可能得到一个有用的答案。 –
我添加了一个截图和更多的信息,如你想要的 – Orsu