-
Notifications
You must be signed in to change notification settings - Fork 0
/
property.component.ts
44 lines (38 loc) · 1.36 KB
/
property.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { DataService } from './../../services/data.service';
import { Country, State } from '../../models/country-state';
@Component({
selector: 'app-property',
templateUrl: './property.component.html',
styleUrls: ['./property.component.scss'],
})
export class PropertyComponent implements OnInit {
public propertyForm: FormGroup;
public selectedCountry: Country = new Country(1, 'USA');
public countries: Country[];
public states: State[];
// tslint:disable-next-line: max-line-length
constructor(private fb: FormBuilder, private dataService: DataService) {
this.countries = this.dataService.getCountries();
this.states = this.dataService.getStates();
}
ngOnInit() {
this.propertyForm = this.fb.group({
companyName: ['', Validators.required],
propertyName: ['', Validators.required],
address: this.fb.group ({
line1: ['', Validators.required],
line2: [''],
line3: [''],
city: ['', Validators.required],
state: ['', Validators.required],
postalCode: ['', Validators.required],
country: ['', Validators.required],
})
});
}
onSelect(countryId) {
this.states = this.dataService.getStates().filter((item) => item.countryid === countryId);
}
}