0
I have an object array and want to perform a function when it changes its value (adding or removing the items).
I’m using the md-checkbox of Angularjs with the checklist-model to include values within my array.
Example:
var vetor = [
{
id: 1,
nome: 'maça'
},
{
id: 2,
nome: 'laranja'
},
{
id: 3,
nome: 'banana'
}
];
alterouValor() {
// minha função
}
So from there, any value that adds or removes should also call the function alterouValor.
Hello Felipe. Your question reminded me that I had a question outline to ask here in the OS regarding the change of state of array. In this case, how is the change made? Direct or Angular? How is this done?
– Cmte Cardeal
@Cmtecardeal Hello. I have a table with
data-ng-repeatof objects (in the example I gave above would be the fruits I could add), so I have acheckboxto select all and one for each fruit. When I select some of thecheckbox, automatically the object is already added in my list I set bychecklist-model. I don’t know if it’s clearer.– Luiz Felipe Rodrigues