如何正确包含文件?

时间:2017-03-18 14:38:04

标签: angular

我有路由问题,因为我使用laravel作为支持,我发现他们添加了这个帖子:

import {bootstrap} from '@angular/platform-browser-dynamic';
import {provide} from '@angular/core';
import {AppComponent} from './app.component';
import {HTTP_PROVIDERS} from '@angular/http';
import { Http, Response } from '@angular/http';
import 'rxjs/Rx';
import {
  LocationStrategy,
  HashLocationStrategy,
}
from '@angular/common';
import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from '@angular/router';
bootstrap(AppComponent, [
    ROUTER_PROVIDERS,
    ROUTER_DIRECTIVES,
    HTTP_PROVIDERS,
    provide(LocationStrategy, {useClass: HashLocationStrategy})
]);

但我得到的错误是他们没有导出成员:

import {bootstrap} from '@angular/platform-browser-dynamic';
import {provide} from '@angular/core';
import {HTTP_PROVIDERS} from '@angular/http';

我也得到错误:

import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from '@angular/router';

有任何建议如何解决这个问题?

1 个答案:

答案 0 :(得分:2)

这种用法,

import {ROUTER_DIRECTIVES, ROUTER_PROVIDERS} from '@angular/router';

适用于弃用路由器(测试版)。我们现在有@NgModule和路由器特定模块

import { RouterModule } from '@angular/router';

请按照https://angular.io/docs/ts/latest/guide/

上的最新文档进行操作
相关问题