- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
当我使用 npm 版本 4.6.1 运行我的 angular 2 应用程序时,出现以下错误。我的 ng build 和 gulp 在项目上运行良好。任何评论/帮助表示赞赏。谢谢。
@angular/cli: 1.0.0
node: 6.10.0
os: linux x64
@angular/cli: 1.0.0
@angular/common: 2.4.10
@angular/compiler: 2.4.10
@angular/compiler-cli: 2.4.10
@angular/core: 2.4.10
@angular/forms: 2.4.10
@angular/http: 2.4.10
@angular/platform-browser: 2.4.10
@angular/platform-browser-dynamic: 2.4.10
@angular/platform-server: 2.4.10
@angular/router: 3.4.10
app.module.ts
import { BrowserModule, Title } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { CookieService } from 'angular2-cookie/core';
// shared gaming components
import { UrlParserService } from 'component-ng2-common/lib/url-parser-
service';
import { RequestOptions } from 'component-ng2-common/lib/request-options';
import { NG2CommonModule } from 'component-ng2-common/ng2-common.module';
// application wide
import { AppComponent } from './app.component';
import { routing, appRoutingProviders } from './app-routing.module';
import { LastRouterService } from './last-route.service';
import { FilterControlComponent} from "./shared/reportControls";
// Before
import { CDSEDetailsComponent, DirectDebitBankDetailsComponent,
MachineDetailsComponent,} from "./reports";
// After
import { CDSEDetailsComponent } from "./reports/cdse-details/cdse-details-
component";
import { DirectDebitBankDetailsComponent } from "./reports/direct-debit-
bank-details/direct-debit-bank-details-component";
import { MachineDetailsComponent } from "./reports/machine-details/machine-
details-component";
import {MachineSearchComponent} from "./search/machine-search-component";
@NgModule({
declarations: [
AppComponent,
FilterControlComponent,
CDSEDetailsComponent,
DirectDebitBankDetailsComponent,
MachineDetailsComponent,
MachineSearchComponent,
],
imports: [
BrowserModule,
FormsModule,
ReactiveFormsModule,
HttpModule,
routing,
NG2CommonModule,
],
providers: [appRoutingProviders, LastRouterService, CookieService,
UrlParserService, RequestOptions, Title],
exports: [ FilterControlComponent ],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.ts
import { Component } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { Router, NavigationEnd } from '@angular/router';
import { LastRouterService } from './last-route.service';
import { IdleService } from 'component-ng2-common/component-ng2-common';
@Component({
selector: "app-project",
templateUrl: './app.component.html',
})
export class AppComponent {
public constructor( private titleService: Title, private router: Router,
lastrouterservice: LastRouterService,
private idleService: IdleService) {
router.events.subscribe(event => {
if (event instanceof NavigationEnd) {
let title = this.getTitle(router.routerState,
router.routerState.root).join(' ').replace(/,\s*$/, '');
titleService.setTitle(title);
}
});
}
public getTitle(state, parent) {
let data = [];
if (parent && parent.snapshot.data && parent.snapshot.data.title) {
data.push(parent.snapshot.data.title);
}
if (state && parent) {
data.push(this.getTitle(state, state.firstChild(parent)));
}
return data;
}
public ngOnInit() {
// 60 secs of no activity = idle then after 20 minutes of further
inactivity the user is logged out.
this.idleService.setupIdle(60, 1200);
}
}
app-routing.module.ts
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
//Before
import { CDSEDetailsComponent, DirectDebitBankDetailsComponent, MachineDetailsComponent, } from "./reports";
//After
import { CDSEDetailsComponent } from "./reports/cdse-details/cdse-details-component";
import { DirectDebitBankDetailsComponent } from "./reports/direct-debit-bank-details/direct-debit-bank-details-component";
import { MachineDetailsComponent } from "./reports/machine-details/machine-details-component";
import {MachineSearchComponent} from "./search/machine-search-component";
const routes: Routes = [
{
component: MachineDetailsComponent,
data: { menuKey: "pOverview", title: Machine Details" },
path: "machineDetails/:vId/:gid",
},
{
component: MachineSearchComponent,
data: { menuKey: "machineSearch", title: "Search for a Machine" },
path: "machineSearch",
},
{
component: DirectDebitBankDetailsComponent,
data: { menuKey: "DirectDebitBankDetails", title: "DGR Direct Debit Bank Details" },
path: "directDebitBankDetails",
},
{
component: CDSEDetailsComponent,
data : { title : "CDSE Details Report"},
path: "CDSEDetailsReport",
},
{
redirectTo: '/pOverview',
path: '',
data: { menuKey: "pOverview", title: "Ps Overview" },
pathMatch: 'full'
}
];
export const appRoutingProviders: any[] = [];
export const routing: ModuleWithProviders = RouterModule.forRoot(routes);
last-route.service.ts
import { Injectable } from '@angular/core';
import { Router, NavigationEnd, NavigationStart } from '@angular/router';
@Injectable()
export class LastRouterService {
lastRoute = "";
constructor(router: Router) {
router.events.pairwise().subscribe((e) => {
if (e[0] instanceof NavigationEnd && e[1] instanceof NavigationStart) {
this.lastRoute = (e[0] as NavigationEnd).urlAfterRedirects;
}
});
}
}
app.component.html
<ng2common-site-header></ng2common-site-header>
<div class="full height">
<app-mainmenu></app-mainmenu>
<div class="content">
<router-outlet></router-outlet>
</div>
<ng2common-site-footer [jurisdiction]="ABC"></ng2common-site-footer>
</div>
main.ts
import './polyfills.ts';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from './environments/environment';
import { AppModule } from './app/';
if (environment.production) {
enableProdMode();
}
platformBrowserDynamic().bootstrapModule(AppModule);
src/app文件夹下的index.ts
export * from "./app.component";
export * from "./app.module";
index.html
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Title - Project</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="<<uxBaseUrl>>/semantic/semantic.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.14.1/moment.min.js"></script>
<script src="<<uxBaseUrl>>/scripts/script-pack.min.js"></script>
<script src="<<uxBaseUrl>>/scripts/daterangepicker.js"></script>
<!-- FAVICONS -->
<link rel="apple-touch-icon" sizes="180x180" href="<<uxBaseUrl>>/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" href="<<uxBaseUrl>>/favicon/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="<<uxBaseUrl>>/favicon/favicon-16x16.png" sizes="16x16">
<link rel="manifest" href="<<uxBaseUrl>>/favicon/manifest.json">
<link rel="mask-icon" href="<<uxBaseUrl>>/favicon/safari-pinned-tab.svg" color="#de2828">
<meta name="theme-color" content="#ffffff">
</head>
<body class="mWrapper">
<app-project></app-project>
</body>
</html>
控制台错误日志
Error: Unexpected value 'undefined' declared by the module 'AppModule' at SyntaxError.ZoneAwareError (http://test-project-test.com/vendor.bundle.js:122965:33) at SyntaxError.BaseError [as constructor] (http://test-project-test.com/vendor.bundle.js:92472:16) at new SyntaxError (http://test-project-test.com/vendor.bundle.js:11029:16) at http://test-project-test.com/vendor.bundle.js:23759:40 at Array.forEach (native) at CompileMetadataResolver.getNgModuleMetadata (http://test-project-test.com/vendor.bundle.js:23757:54) at JitCompiler._loadModules (http://test-project-test.com/vendor.bundle.js:59144:64) at JitCompiler._compileModuleAndComponents (http://test-project-test.com/vendor.bundle.js:59104:52) at JitCompiler.compileModuleAsync (http://test-project-test.com/vendor.bundle.js:59070:21) at PlatformRef_._bootstrapModuleWithZone (http://test-project-test.com/vendor.bundle.js:45972:25) at PlatformRef_.bootstrapModule (http://test-project-test.com/vendor.bundle.js:45947:21) at Object.594 (http://test-project-test.com/main.bundle.js:787:124) at __webpack_require__ (http://test-project-test.com/inline.bundle.js:53:30) at Object.1194 (http://test-project-test.com/main.bundle.js:6:18) at __webpack_require__ (http://test-project-test.com/inline.bundle.js:53:30)
最佳答案
上述错误的解决方案是纠正我导入以下组件的方式
之前
从“./reports”导入 {CDSEDetailsComponent、DirectDebitBankDetailsComponent、MachineDetailsComponent,};
之后
从“./reports/cdse-details/cdse-details-component”导入{CDSEDetailsComponent};
从“./reports/direct-debit-bank-details/direct-debit-bank-detai ls-component”导入 { DirectDebitBankDetailsComponent };
从“./reports/machine-details/machine-details-component”导入{MachineDetailsComponent};
上面的改动需要在app.module & app-routing.module中进行
关于angular - 模块 'undefined' 在 SyntaxError.ZoneAwareError 声明的意外值 'AppModule',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43794233/
我在 Python 2 中尝试了这段代码: def NewFunction(): return '£' 但我收到一条错误消息: SyntaxError: Non-ASCII character
我正在学习xpath,并且我正尝试从html usint xpath获取一些数据 我发现谷歌浏览器可以选择“复制xpath”,效果很好 但不适用于这个例子 some divs
我是 ruby 的初学者。我想修复其中一个邮件软件中的错误。我应用的修复代码如下: @headers[:recipient] = { "To" => (cc.map do |p|
我是初学者级别的python用户,当我在终端中键入以下内容时: $ pydoc Inleesgenbank.py 我收到以下错误消息: ./Inleesgenbank.py中的问题-:语法无效(Inl
我正在编写用于解析电子邮件的脚本,但是以下部分的for循环上有一些SyntaxError: def main(): writer = csv.DictWriter(open('feature
我正在尝试在python33中创建分发文件,但没有成功。 我用嵌套器名称创建了一个文件夹,并在Windows 8的C驱动程序中放入了python33。 此文件夹有2个文件。 nester.py和set
当我尝试导入NumPy时,突然出现以下错误: 更具体地说,它在我键入时显示: import numpy as np 要不就: import numpy 它也会在Python控制台中发生,如下所示: P
在我的 HTML 文件中,我有一行(如下)通过 WiFi 从设备获取响应并使数据可用于我的 JavaScript,它运行良好,除非响应文本中有错误并停止。 响应是一个代表 JavaScript 变量的
我开始使用 Javascript OOP,我编写了我的第一个类,但我在控制台中收到消息错误 这是类(class): class Quote{ deleteQuote(callback){ $(
我正在使用argparse来解析参数,但是当我得到args.global时,出现了一个奇怪的错误,我不知道我哪里做错了 ... parser.add_argument('-u','--update',
已关闭。这个问题是 not reproducible or was caused by typos 。目前不接受答案。 这个问题是由拼写错误或无法再重现的问题引起的。虽然类似的问题可能是 on-top
我正在使用argparse来解析参数,但是当我得到args.global时,出现了一个奇怪的错误,我不知道我哪里做错了 ... parser.add_argument('-u','--update',
有什么不同?为什么它会在函数 a() 中出错? function a(){ 1 == 1 ? return true: ""; // Uncaught SyntaxError: Unexpe
我有一个 python 脚本,其中包含如下函数参数的类型声明: def dump_var(v: Variable, name: str = None): 据我所知,这是一个为函数设置输入参数类型的有效
我正在尝试从命令行运行 Python 脚本,这是我的脚本: import sys def printsomething(sys.argv): text = str(sys.argv[1])
我在 macbook 上使用终端将数据打印到打开的文件中: >>> out=open("test_output.txt","w") >>> print("hello",file=out) File
我想排除以下代码产生的错误,但我不知道如何。 from datetime import datetime try: date = datetime(2009, 12a, 31) except:
我想在动态生成的列表中放置一个 onclick 事件。我不能按原样使用它,例如 updateRoomID(arg) ,因为它会立即开火。所以我把它放在一个匿名函数中,按照网上各种来源的建议:funct
我有以下脚本: 测试.py: import sys try: import random print random.random() except: print sys.exc
这个问题在这里已经有了答案: "+=" causing SyntaxError in Python (6 个答案) 关闭 3 年前。 在我的代码中有这些行: if numVotes == 0:
我是一名优秀的程序员,十分优秀!