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

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

问题描述

我是 angularjs 的新手,我在使用控制器时遇到了一些问题.当我尝试在 angular.module 中放入一些东西时,我只能指定名称,如果我在需要部分放入一些东西,所有页面都会停止工作.例如:如果我输入 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 requires 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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