Skip to content

Instantly share code, notes, and snippets.

@desaroxx
Last active December 12, 2015 23:58
Show Gist options
  • Save desaroxx/61600137b57bf1d75afa to your computer and use it in GitHub Desktop.
Save desaroxx/61600137b57bf1d75afa to your computer and use it in GitHub Desktop.
namespace app.directives.weather {
class WeatherController {
public static $inject: Array<string> = ["temperatureService"];
public currentTemperature: number;
constructor(private temperatureService: app.services.TemperatureService) {
this.loadTemperature();
}
private loadTemperature(): void {
this.temperatureService.getTemperature()
.then((temp) => {
this.currentTemperature = temp;
});
}
}
angular.module("app").directive("weather", (): ng.IDirective => {
return {
restrict: 'E',
controller: WeatherController,
controllerAs: 'weatherCtrl',
templateUrl: 'directives/weather/weather-template.html'
};
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment