Angular 2 Full App Tutorial - Weather App - #7 Adding a Service

preview_player
Показать описание
Join me in this Tutorial Video Series on Angular 2 where I will build a neat little Weather App using Components, Databinding, HTTP, Services, Observables and more!
This videos shows how to integrate a Service in your Angular 2 app to centralize parts of your app logic.

More detailed explanations about Angular 2 dependency injection and services:

Github repository with source code (videos have their own branches):

See you in the videos!
Рекомендации по теме
Комментарии
Автор

hello there! Please help. I don t know what i am doing wrong !

the code works perfectly until i add

constructor(private _weatherService: WeatherService){}
this.weatherItems =
providers: [WeatherService]
and I import

import {WeatherService} from "./weather.service";

for now her is the code


import {Component, OnInit} from "angular2/core";
import {WeatherItemComponent} from "./weather-item.component";
import {WeatherItem} from "./weather-item";
import {WeatherService} from "./weather.service";
@Component({
selector: 'weather-list',
template: `
<section class="weather-list">
<weather-item *ngFor="#weatherItem of weatherItems"
</section>
`,
directives: [WeatherItemComponent],
providers: [WeatherService]

})
export class WeatherListComponent implements OnInit {
weatherItems:WeatherItem[];

constructor(private _weatherService: WeatherService){}

ngOnInit():any {
//this.weatherItems = WEATHER_ITEMS;
this.weatherItems =

}

}

thanks

franckbarry
Автор

Great vid! Are you planning on going through basic examples of using http in next videos? I'd love to see it ;)

tititoto