错误消息
VM556 angular2-polyfills.js:349错误:必须定义令牌!(...)
或
错误TS2305:模块'" / node_modules / angular2 / router"'没有导出的成员' LocationStrategy'。
错误TS2305:模块'" / node_modules / angular2 / router"'没有导出的成员' HashLocationStrategy'。
错误TS2305:模块'" / node_modules / angular2 / router"'没有导出的成员'位置'。
如何修复
答案 0 :(得分:29)
更新> = rc.5
@NgModule({
providers: [{ provide: LocationStrategy, useClass: HashLocationStrategy}]
})
export class AppModule {}
更新> = rc.0
import {
PlatformLocation,
Location,
LocationStrategy,
HashLocationStrategy,
PathLocationStrategy,
APP_BASE_HREF}
from '@angular/common';
import {BrowserPlatformLocation} from '@angular/platform-browser';
<强>原始强>
更改
import {ROUTER_PROVIDERS, LocationStrategy, HashLocationStrategy} from 'angular2/router';
到
import {ROUTER_PROVIDERS} from 'angular2/router';
import {LocationStrategy, HashLocationStrategy} from 'angular2/platform/common';
另见
- https://github.com/angular/angular/issues/8229
移出的出口的完整清单:
- https://github.com/angular/angular/pull/8230/files
import {
PlatformLocation,
Location,
LocationStrategy,
HashLocationStrategy,
PathLocationStrategy,
APP_BASE_HREF}
from 'angular2/platform/common';
import {BrowserPlatformLocation} from 'angular2/src/platform/browser/location/browser_platform_location';
此更改通常导致的另一个错误是
location.createComponent不是函数