Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tmp: string;
- constructor(private http: Http) {
- this.tmp = "load";
- this.GetUsers();
- }
- ngOnInit() {
- setTimeout(console.log("Hello"), 2000);
- }
- GetUsers() {
- this.http.get('http://localhost:1337/api/users')
- .toPromise()
- .then(function(response) {
- this.tmp = "success"
- })
- .catch(this.handleError);
- public tmp: string;
- constructor(private http: HttpClient) { // не забудь заимпортить этот модуль
- }
- ngOnInit() {
- setTimeout(console.log("Hello"), 2000);
- this.GetUsers()
- .do(() => this.tmp = 'load')
- .subscribe(data => {
- this.tmp = data;
- });
- }
- private getUsers(): Observable<any> {
- return this.http.get<any>('http://localhost:1337/api/users')
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement