-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.component.ts
47 lines (41 loc) · 1.08 KB
/
app.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
45
46
47
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { propertyStringPathFactory } from 'property-string-path';
import { User } from './models/user';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent implements OnInit {
public title = 'ng-prop-string';
public form: FormGroup;
public controlPath = propertyStringPathFactory<User>();
constructor(private fb: FormBuilder) {}
public ngOnInit(): void {
this.form = this.fb.group({
id: '',
name: '',
username: '',
email: '',
phone: '',
website: '',
company: this.fb.group({
name: '',
catchPhrase: '',
bs: '',
}),
address: this.fb.group({
street: '',
suite: '',
city: '',
zipcode: '',
geo: this.fb.group({
lat: '',
lng: '',
}),
}),
});
this.form.get(this.controlPath('address.geo.lat')).valueChanges.subscribe(console.log);
}
}