Skip to content

Instantly share code, notes, and snippets.

@thisiszoaib
Created July 9, 2020 11:32
Show Gist options
  • Select an option

  • Save thisiszoaib/a038174bbf1e87aee285542d2b96c6a2 to your computer and use it in GitHub Desktop.

Select an option

Save thisiszoaib/a038174bbf1e87aee285542d2b96c6a2 to your computer and use it in GitHub Desktop.
Weather 2
@Component({
selector: "app-root",
templateUrl: "./app.component.html",
styleUrls: ["./app.component.scss"]
})
export class AppComponent implements OnInit, OnDestroy {
cities = ["London", "Paris", "Moscow", "New York", "Karachi", "Sydney"];
cityControl: FormControl;
constructor(private router: Router) {}
ngOnInit() {
this.cityControl = new FormControl("");
this.cityControl.valueChanges
.subscribe(value => {
this.router.navigate([value]);
});
}
ngOnDestroy() {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment