angularjs - 为什么我不能从名为 'users' 的文件夹加载文件?

标签 angularjs node.js http directory naming

我正在开发一个 MEAN 应用程序。我的 Angular 文件夹结构如下: enter image description here

并在我的应用程序中出现以下错误: enter image description here

但是当我将“用户”文件夹重命名为其他任何名称(如“用户”)时,它起作用了: enter image description here enter image description here

这是为什么?

编辑:

请求的 app.js:

var mainModuleName = 'mean';

var mainModule = angular.module(mainModuleName, ['ngRoute', 'example', 'users']);

mainModule.config(['$locationProvider', function($locationProvider) {
  $locationProvider.hashPrefix('!');
}]);

if (window.location.hash === '#_=_') window.location.hash - '#!';

angular.element(document).ready(function() {
  angular.bootstrap(document, [mainModuleName]);
});

最佳答案

我认为您在第一种情况下缺少 angular.module 的第二个参数。你应该有

angular.module('users',[]).factory('auth',[auth]);

因为您没有括号,所以您实际上并没有创建用户的新实例,这就是错误的来源。

此链接可能有帮助 https://docs.angularjs.org/api/ng/function/angular.module

关于angularjs - 为什么我不能从名为 'users' 的文件夹加载文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32314642/

相关文章:

javascript - 在 Javascript 中将文件图像附加到 FormData(Http 请求)

Angular JS。根据当前路由设置默认标题

javascript - 即使在进行更改后,Node js 也会在控制台中显示旧文件

http - Hadoop-提取失败太多-HTTP响应代码:500

javascript - 跨源 PostMessage 方法失败

javascript - 使用 ngModel 的 Angular 递归指令

javascript - Angular ui-router 动态参数仅适用于特定子状态

javascript - 如何从路由文件中在 socket.io 中发出事件?

javascript - 通过nginx运行两个nodejs实例

http - 如何发布Facebook成绩?