Let's say I have a simple array object like so:
validationMessages = {
'name': [{
'type': 'required',
'message': 'Name is required.',
'enabled': 1
},
{
'type': 'maxlength',
'message': 'Name cannot be more than 50 characters long.',
'enabled': 0
}],
'description': [
{
'type': 'required',
'message': 'Description is required.',
'enabled': 0
},
]
};
I'm then displaying on load in my UI like so:
<div *ngFor="let err of validationMessages.name">
<div *ngIf="err.enabled == 1" class="alert alert-danger">
{{err.message}}
</div>
</div>
Working fine.
However what I'd like to do is be able to update validationMessages.name
array to update a given object to mark enabled
1 or 0. I'd want this then to update/re-run my UI.
I'm sure this can be done using observables, but what am I missing to do this?