【Angular实现预加载延迟模块实例分享】教程文章相关的互联网学习教程文章

javascript – 在AngularJS测试中交换模块值【代码】

我有一个带有问候工厂的模块:angular.module('someModule', []).factory('greet', function(name) {return function() {return 'Hi ' + name + '!';}});此工厂注入一个名称,该名称是在其他模块中定义的值.angular.module('someOtherModule', []).value('name', 'example');在测试这个模块时,我希望能够多次更改我的注入名称的值(每次测试一次),以便我的测试看起来像:// In my test file…// Initialise the module I am testing ...

javascript – 强制Angular 2子模块中的服务实例化(AngularJS运行块的替代)【代码】

我在子模块中有一个服务包装一些第三方模块,实例化并初始化其服务以准备在app中使用.@Injectable() class SubmoduleInitializerService {constructor (thirdPartyService: ThirdPartyService) {thirdPartyService.initialize(...);...} }@NgModule({imports: [ThirdPartyModule],exports: [ThirdPartyModule],providers: [ThirdPartyService,SubmoduleInitializerService] }) class AppSubmodule {}ThirdPartyService不是直接在app...

javascript – Gulp Babel不提供Angular模块【代码】

在我的gulp文件中添加gulp babel之后,我的Angular应用程序中出现以下错误.我需要这个来改变和缩小我的ES6:Cannot set property ‘0’ of undefined我认为角文件保护程序不喜欢babelfication. 导致这些错误:angular.js:33 Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to: Error: [$injector:nomod] Module ‘app’ is not available!但我可以看到模块正在加载客户端:Gulp任务:注意:当我开始穿...

javascript – Angular – 模块化地定义所有服务【代码】

说我有这样的服务模块// services/someService.js export default function($q) {return $q.doSomething(); }// services/anotherService.js export default function($state) {return $state.doAnotherThing(); }并说我有一个服务索引文件// services/index.js import someService from 'someService'; import antoherService from 'anotherService';export default {someService: someService,anotherService: anotherService, }...

javascript – AngularJs – 已定义模块,但仍然出现“不可用”错误【代码】

我正在尝试使用angular指令构建密码匹配机制,似乎我错过了一些东西.我定义了ng-app和ng-controller但是我仍然收到一条错误消息,指出模块没有定义. Jsfiddle here.Uncaught Error: [$injector:modulerr] Failed to instantiate module myApp due to: Error: [$injector:nomod] Module 'myApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the...

javascript – 找不到模块’chart.js’.)Angular 2【代码】

嘿大家我正在使用Angular2 CLI并尝试导入chart.js模块,但每次我运行服务器时都会得到一个’找不到模块’的图表.js“’import { Component } from '@angular/core'; import Chart from 'chart.js';@Component({selector: 'app-root',templateUrl: './app.component.html'})export class AppComponent {title = 'Test';let myChart = new Chart({}); };解决方法:不幸的是我遇到了同样的问题. 我正在使用cdn并声明变量如下:declare l...

javascript – 使用Ionic和Webpack导入ngstorage时无法解析模块’angular’【代码】

我正在使用Ionic与Webpack和Typescript实现一个应用程序.我通过npm安装’ngstorage’并尝试导入条目ts文件,但Webpack显示错误 – ‘无法解析模块’angular”. 我搜索了这个错误并意识到我需要在package.json文件和node_modules中包含angular.但是,ionic-sdk模块已经包含了角度.所以它反而在浏览器中显示一个不可接受的错误,我试图多次加载角度. Webpack是否有办法跳过模块解析器或指向角度模块到ionic-sdk模块的路径?或者有其他建...

javascript – 如何在两个不同的Angular模块中使用管道【代码】

我有一个烟斗@Pipe({name: 'keys'}) export class KeysPipe implements PipeTransform {transform(value, args:string[]) : any {.....return keys;} }我有两个模块,我需要使用它.如果我在这两个模块中执行类似的操作,我会收到一条错误消息“两个模块声明了KeysPipe” Module1,Module2:declarations: [KeysPipe],然后我尝试通过它自己的模块导出KeysPipe,以便我可以将它导入到我需要使用它的两个模块中@NgModule({declarations: [...

javascript – Angular2错误 – 是否包含平台模块(BrowserModule)?【代码】

我只是想在Angular2中运行一个简单的index.html页面,但它在console中的zone.js中显示错误:Unhandled Promise rejection: No ErrorHandler. Is platform module (BrowserModule) included? ; Zone: <root> ; Task: Promise.then ; Value: Error: No ErrorHandler. Is platform module (BrowserModule) included?at eval (application_ref.ts:364)at ZoneDelegate.invoke (zone.js:391)at Object.onInvoke (ng_zone.ts:296)at ZoneD...

javascript – Angular – 指令和使用模块【代码】

在研究了各种不同的项目并阅读尽可能多的文档后,我遇到了如何在我的应用程序中包含指令的问题.该应用程序的设置如下: app.js – 只是顶部angular.module('ngDashboard', ['ngCookies','ngResource','ngDashboard.filters', 'ngDashboard.services', 'ngDashboard.directives'])除了(它是一个从一个例子重写的应用程序)之外,所有模块都能正常工作,因为这些指令根本不起作用: directives.js – 以下不起作用,不在视图上执行指令:...