问题标签 [angularjs-module]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
3 回答
1017 浏览

angularjs - Angularjs Share Constant between Modules

Say I have angularjs modules called core, customer, and admin. Both customer and admin include core. I want both modules' sites to use the same header, which has a controller (HeaderController). When a user logs in to the site backed by the customer module, I create a constant with the user information on the core module. Wherever I go within the customer module, that constant has the data I put there. There's a link to go to the site backed the admin module and I want to be able to access that constant with the user info from admin (on the HeaderController). Below you'll find snippets of my code. Right now everything on customer works but when I go to admin I get the following:

Error: [$injector:unpr] Unknown provider: currentUserProvider <- currentUser <- HeaderController

Index.cshtml for customer

Module for admin

Module for customer

Controller where I need to access currentUser (constant)

0 投票
1 回答
192 浏览

javascript - 如何修复 angular.module 不能与依赖模块一起使用?

我很清楚 angular.module 的工作原理,但无论出于何种原因,我都无法理解。

在我的代码中,我有以下内容

但是我的代码仅在没有依赖模块的数组时才有效,如下所示:

我对导致问题的原因一无所知,因为我一直都知道需要空数组。

0 投票
2 回答
147 浏览

angularjs - 在 Angular 中,我们可以有通用的 App 模块还是可以有单独的模块?

我和我的同事讨论过使用 Angular js 设置我们的应用程序。

我是说我们可以创建一个全局通用模块应用程序(例如:employeeApp),它将被整个应用程序中使用的所有模块使用。因此,如果必须发生任何常见的注入,那么我们将它们注入到 Common Module App 中,我们不需要注入到单个 Module 中。

但他的重点不是创建全球通用模块应用程序。因为 1. 将被 javascript 工具抱怨的全局变量(例如:jshint)。2.想让每个模块都独立。如果在特定模块中发生任何问题,它不会影响其他模块。

您如何看待这种做法。哪一个比另一个更好。?

0 投票
1 回答
41 浏览

angularjs - Most standard way to handle communication between isolated modules in Angular 1.x

I am working on a set of enterprise style applications that share some common functionality. An example of this would be navbar functionality such as sorting/ breadcrumbs, etc. It seems pretty straight forward to allow this by creating multiple modules. I have an example plnkr of what I am talking about.

My question is, when I need to send a value from app to app2 what would I do? Would I just create some sort of JS listener?

0 投票
1 回答
73 浏览

javascript - 60 分钟内的 Angular 路由问题

我想知道是否有人可以快速浏览我的代码并让我知道我是否遗漏了什么。我正在尝试学习 Angular.js,并且在 60 分钟的视频中一直在使用著名的Angular.js。然而,我遇到的问题是 angular 从那以后已经更新,事情有点不同。结果,我无法正确编排我的路线。非常感谢任何人提前。

我真正想知道的是,任何人都可以告诉我为了使这些路线正常工作而我缺少什么吗?

下面是我的 html 中的脚本。我跟着这本书,结果它们是我的 index.html 页面中的脚本标签。

这分别是我的视图#1 和视图#2。我觉得一切都是正确的,但是我无法让任何客户的名字出现。

0 投票
1 回答
111 浏览

angularjs - 何时指定 angularjs 依赖模块?

我见过一些你可以立即在提供者中使用角度服务的例子,例如:

相对

两者有什么区别?什么时候隐含资源,不需要方括号符号?

编辑:我有一个例子有一些混乱,我问是因为我不想破坏缩小。

0 投票
0 回答
605 浏览

javascript - 如何设置 Forge 库的依赖关系?

我正在尝试在我的项目中包含这个库(Digital Bazaar / Forge): https ://github.com/digitalbazaar/forge

为了包含依赖项并让 forge 对象通过我的angularjs应用程序可用,我遵循了缩小代码并在 index.html 中注入链接的步骤:

当我在云环境(cloud9 中的 nodejs 项目)中测试它时,这工作正常,但是当我使用 部署应用程序时Phonegap Build,依赖项和对象forge似乎在设备上不可用。

我做错了什么以及如何解决?

0 投票
3 回答
1292 浏览

angularjs - 从单独的角度模块获取服务

您有 2 个角度模块,其中一个模块具有您想在另一个模块中使用的服务:

问题是 - 您如何在模块 B 中使用“FirstService”?

这失败了:

这些也失败了:

0 投票
1 回答
1098 浏览

angularjs - 添加角度模块

我正在尝试将 angular-gantt 插件添加到我的应用程序中。首先;

然后,当我的应用程序需要 angular-gantt 时,我想向“myApp”添加一些额外的模块,例如;

但是当我这样做时,页面消失了,没有任何效果。我怎么解决这个问题。

0 投票
1 回答
562 浏览

angularjs - AngularJS:我可以将回调附加到模块的运行方法吗?

高级问题:

  • 我想知道当前用户是否已登录 Google Plus。

部分解决方案:

并发症:

具体问题:

  • 我想将一个回调方法附加到 onload 参数,但异步 JavaScript 获取https://apis.google.com/js/client.js发生在 AngularJS 的 run 方法中。

-> 模块初始化:

尽管 Google 建议您https://apis.google.com/js/client.js异步获取,但我并不喜欢它。但我想将大部分 Google+ 集成代码保留在 AngularJS 提供程序或 AngularJS 服务中。

任何帮助,将不胜感激。