Created
January 4, 2020 09:39
-
-
Save Kalpesh300/1d643d6de40f47121bd5878f213c2fd4 to your computer and use it in GitHub Desktop.
Demo Component
This file contains 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 { Component, OnInit, Input } from '@angular/core'; | |
import { HttpClient } from '@angular/common/http'; | |
import { FormControl } from '@angular/forms'; | |
@Component({ | |
selector: 'app-demo', | |
templateUrl: './demo.component.html', | |
styleUrls: ['./demo.component.scss'] | |
}) | |
export class Demo implements OnInit { | |
tempProperty: string; | |
tempData: any; | |
tempFormControl: FormControl; | |
constructor(private httpClient: HttpClient) { | |
this.tempFromControl = new FormControl(null); | |
} | |
ngOnInit() { | |
initialization(); | |
getData(); | |
makeSubscriptions(); | |
} | |
initialization() { | |
this.tempProperty = 'Hello World!'; | |
} | |
getData() { | |
this.httpClient.get('https://apiendpoint/').subscribe( | |
(response) => { | |
this.tempData = response; | |
} | |
); | |
} | |
makeSubscriptions() { | |
this.tempFormControl.valueChanges.subscribe( | |
(value) => { | |
console.log(value); | |
} | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment