Unfortunately my reputation is too low to ask this as a comment.
Where does the object.property
gets its value from?
Are you using input fields on a form in your HTML?
If you are using a input fields on a form to capture object.name
and object.title
then it would be easier/best to use form validators
with formGroup
and formBuilder
import{ Validators, FormBuilder, FormGroup, FormControl }from'@angular/forms';
This will make sure that your object properties always have data in them or it will let you display to the end user that something is wrong with their information.
There is a lot of information out there on validators, but they are rather simple to implement, and it is mostly done on the page.html
.
If you are getting your data from a service or just want to check the object
1 last time before you doSomething()
then you will need to loop through each of the properties in the object.
Determining if all attributes on a javascript object are null or an empty string