angular.module要求不起作用 [英] angular.module requires doesn't work

查看:125
本文介绍了angular.module要求不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是angularjs的新手,我在控制器方面遇到了一些问题.当我尝试在angular.module中放置某些内容时,如果我在require部分中放置了某些内容,则所有页面都将停止工作,我只能指定名称.例如: 如果我输入angular.module('name',[])则不起作用,但是如果我输入angular.module('name')则它可以正常工作.有人知道为什么吗?

I'm new with angularjs and I'm having some problems with the controllers. When I try to put something in the angular.module I only can specify the name, if I put something in the requires part all the page stop working. For example: If I put angular.module('name',[]) it doesn't work but if I put angular.module('name') it works properly. Somebody knows why is it?

推荐答案

此语句

angular.module('name',[])

创建一个模块,而此语句加载该模块

creates a module, whereas this statement loads the module

angular.module('name')

第一个语句应使用一次来定义具有依赖项的模块.之后,应使用第二种格式.

The first statement should be used once to define the module with dependencies. After that the second format should be used.

如果再次使用第一种语法,则会导致模块的重新定义,并且模块上现有的注册都会丢失.

If you use the first syntax again this leads to redefining of module and existing registration on the module are lost.

这篇关于angular.module要求不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆