无论出于何种原因,Angular2对我的某个页面不满意。其他页面似乎工作正常。仅在quinoa页面上产生的错误是: EXCEPTION:错误:未捕获(在承诺中):SyntaxError:无效或意外的令牌
由于项目现在非常小,并且据我所知,与angular2快速入门指南相同,因此不确定导致错误的原因。
任何帮助都会很棒。感谢!!!
main.ts
file1_OTHER.txt
main.component.ts
import { bootstrap } from '@angular/platform-browser-dynamic';
import { ROUTER_PROVIDERS } from '@angular/router-deprecated';
import { MainComponent } from './main.component';
import { Title } from '@angular/platform-browser';
bootstrap(MainComponent, [ Title, ROUTER_PROVIDERS ]);
错误组件: quinoa.component.ts
// Import the native Angular services.
import { Component } from "@angular/core";
import { Title } from '@angular/platform-browser';
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from '@angular/router-deprecated';
import { HomeComponent } from './home.component';
import { QuinoaComponent } from './quinoa.component';
import { NaturalHerbsComponent } from './naturalherbs.component';
@Component({
selector: 'c-main',
templateUrl: 'app/html/main.component.html',
directives: [ROUTER_DIRECTIVES],
providers: [ROUTER_PROVIDERS]
})
@RouteConfig([
{
path: '/home',
name: 'Home',
component: HomeComponent,
useAsDefault: true
},
{
path: '/quinoa',
name: 'SuperfoodQuinoa',
component: QuinoaComponent
},
{
path: '/naturalherbs',
name: 'NaturalHerbs',
component: NaturalHerbsComponent
}
])
export class MainComponent {
/*public constructor( private titleService: Title ) { }
public setTitle( newTitle: string) {
this.titleService.setTitle( newTitle );
}*/
}
答案 0 :(得分:0)
事实证明我正在使用的编辑器会弹出一个问题,询问它是否可以缩进,因为某些原因,angularjs 2不喜欢它。
我使用的编辑器是webstorm 2016。