Skip to content

Instantly share code, notes, and snippets.

@IEvangelist
Created January 12, 2016 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IEvangelist/6a75373f90845cfe3467 to your computer and use it in GitHub Desktop.
Save IEvangelist/6a75373f90845cfe3467 to your computer and use it in GitHub Desktop.
import {Component, OnInit} from "angular2/core";
import {CORE_DIRECTIVES} from "angular2/src/common/directives/core_directives";
import {ApiService} from "./api.service";
@Component({
selector: "numbers",
templateUrl: "/partial/numbers",
providers: [ApiService],
directives: CORE_DIRECTIVES
})
export class ApiComponent implements OnInit {
apiOccurances: number = 0;
data: number[];
isLoading: boolean = false;
constructor(private service: ApiService) { }
ngOnInit() {
this.get();
}
get() {
this.isLoading = true;
this.service.get(json => {
if (json) {
this.data = json.numbers;
this.isLoading = false;
this.apiOccurances++;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment