mirror of
https://github.com/aspnet/JavaScriptServices.git
synced 2025-12-25 19:17:30 +00:00
Use HttpWithStateTransferModule in Angular template
This commit is contained in:
@@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { HttpModule } from '@angular/http';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { HttpWithStateTransferModule } from 'aspnet-angular';
|
||||
|
||||
import { AppComponent } from './components/app/app.component';
|
||||
import { NavMenuComponent } from './components/navmenu/navmenu.component';
|
||||
@@ -21,6 +22,7 @@ import { CounterComponent } from './components/counter/counter.component';
|
||||
imports: [
|
||||
CommonModule,
|
||||
HttpModule,
|
||||
HttpWithStateTransferModule,
|
||||
FormsModule,
|
||||
RouterModule.forRoot([
|
||||
{ path: '', redirectTo: 'home', pathMatch: 'full' },
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { Http } from '@angular/http';
|
||||
import { HttpWithStateTransfer } from 'aspnet-angular';
|
||||
|
||||
@Component({
|
||||
selector: 'fetchdata',
|
||||
@@ -8,7 +8,7 @@ import { Http } from '@angular/http';
|
||||
export class FetchDataComponent {
|
||||
public forecasts: WeatherForecast[];
|
||||
|
||||
constructor(http: Http, @Inject('BASE_URL') baseUrl: string) {
|
||||
constructor(http: HttpWithStateTransfer, @Inject('BASE_URL') baseUrl: string) {
|
||||
http.get(baseUrl + 'api/SampleData/WeatherForecasts').subscribe(result => {
|
||||
this.forecasts = result.json() as WeatherForecast[];
|
||||
}, error => console.error(error));
|
||||
|
||||
Reference in New Issue
Block a user