hello
Here is a sample of the model I am working with:
export interface SiteSetting {
postSetting: PostSetting;
}
export interface PostSetting {
showDataRecordAfterSomeDay: number;
}
I am trying to populate this model in a component and set it as the form value.
postSettingAddFormGroup: FormGroup;
postSettingModel: SiteSetting;
constructor(private formBuilder: FormBuilder, private postsettingService: PostService, private alertService: AlertService, private route: Router) {
this.postSettingModel = {} as SiteSetting;
this.cachedSetting();
}
ngOnInit(): void {
this.initializeForm();
}
ngAfterViewInit(): void {
}
initializeForm(): void {
this.postSettingAddFormGroup = this.formBuilder.group({
showDataRecordAfterSomeDay: ['', Validators.compose([Validators.required, Validators.minLength(0), Validators.maxLength(365)])]
});
}
cachedSetting(): void {
this.postsettingService.getPostSetting().subscribe(data => {
this.postSettingModel.postSettingsModel = data
})
}
I have implemented this code but encountered an issue with postSettingModel
.
What could be causing this problem? How can I troubleshoot this model?