I have a form model that I am using to map my form fields in AngularJS. Since I am updating these fields on a database I want to retrieve the fields once the user submits the form and comes back to it.
form object:
vm.user = {
userBag:[
{
name: nameService.nameBag[0].organizationName
},
{
name: nameService.nameBag[1].organizationName,
},
{
name: nameService.nameBag[2].organizationName,
}
]
};
I have coded the form object to return the database fields but I'm running into an error when the user initially has nothing submitted in the field bc the object is empty. Getting the error:
"TypeError: Cannot read property 'organizationName' of undefined"
nameServie is just a get call that retrieves the get.
How do I make it so that the name fields just return a blank if the nameService is undefined?
name: nameService.nameBag[0] ? nameService.nameBag[0].organizationName : ""nameServieis just a get call that retrieves the get"?