Created
November 24, 2016 11:51
-
-
Save TimDorand/fa588631347a0e1c4e38f3d6562b667f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Response} from '@angular/http'; | |
import { HttpService } from './httpservice.service'; | |
@Component({ | |
selector: 'http-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'], | |
providers:[HttpService] | |
}) | |
export class AppComponent implements OnInit { | |
items:any[]; | |
title = 'http works!'; | |
constructor(private httpservice:HttpService){ | |
} | |
ngOnInit(){ | |
this.httpservice.getData() | |
.subscribe( | |
(data:any) => console.log(data) | |
); | |
} | |
onSubmit(username:string,email:string){ | |
this.httpservice.sendData({username:username,email:email}) | |
.subscribe( | |
(data:any) => console.log(data) | |
); | |
} | |
onGetdata(){ | |
this.httpservice.getMydata() | |
.subscribe( | |
data => { | |
const array = []; | |
for(let key in data){ | |
array.push(data[key]); | |
} | |
this.items=array; | |
} | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment