Cuando intento importar los HTTP_PROVIDERS de angular / http tengo este error:
Error:(3, 9) TS2305: Module ""projectname/node_modules/@angular/http/index"" has no exported member "HTTP_PROVIDERS".
este es mi contenido de archivo:
import { Component } from "@angular/core";
import {GithubService} from "./services/github.service";
import {HTTP_PROVIDERS} from "@angular/http";
@Component({
selector: "my-app",
template: "<h1>My First Angular 2 App</h1><Profile></Profile>",
providers: [ HTTP_PROVIDERS, GithubService ]
})
export class AppComponent { }
Respuestas
9 para la respuesta № 1Si usas> = RC.5 agrega HttpModule
a imports
en @NgModule
en lugar:
@NgModule({
imports: [HttpModule],
...
})
class AppModule {}
2 para la respuesta № 2
¿Qué pasa si quiero escribir un auth-interceptor usando p. Ej.
import { provideAuth } from "angular2-jwt";
...
bootstrap(App, [
HTTP_PROVIDERS,
provideAuth({
headerName: YOUR_HEADER_NAME,
headerPrefix: YOUR_HEADER_PREFIX,
tokenName: YOUR_TOKEN_NAME,
tokenGetter: YOUR_TOKEN_GETTER_FUNCTION,
globalHeaders: [{"Content-Type":"application/json"}],
noJwtError: true,
noTokenScheme: true
})
])
Primero, no hay HTTP_PROVIDERS en @ angular / http. Segundo, no hay bootstrap en @ angular / platform-browser-dynamic
En todas partes encuentras cosas similares cuandodesea escribir su interceptor de autenticación, pero en ninguna parte está escrito cómo hacerlo con la versión de lanzamiento de angular 2 :( Todos los ejemplos ya no funcionan :( ¿Alguien puede decirme cómo escribir un interceptor de autenticación con su versión LIBERADA de angular2, es decir, @angular / *: 2.0.0