0
[SIMULATION using Jsfiddle at the end of the problem description]
The following function performs the insertion of some elements using Angularjs:
$scope.addItem = function (user){
$scope.items.push({
nome: $("input[name='nome']").val(),
email: $("input[name='email']").val(),
soma: sum++
});
user.nome = '';
user.email = '';
};
For each inserted item there is a table of attributes that must be filled.
However, when selecting a state in that table, the state of the other table is also changed.
How to individually manipulate/control each action from the Attributes table (displayed via Modal) using Avascript?
Script that displays/hides fields according to state:
$(document).ready(function(e) {
$('#estado').on('change', function() {
if($(this).val() == "GO"){
$('#insc-go').show();
$('#insc-to').hide();
}
if($(this).val() == "TO"){
$('#insc-to').show();
$('#insc-go').hide();
}
if($(this).val() == ""){
$('#insc-to').hide();
$('#insc-go').hide();
}
});
})
Simulation: https://jsfiddle.net/xs2102e5/
One opinion, the use of jQuery is only complicating your understanding. Try to use only Angular, it will be easier and you will have a better understanding of what needs to be done.
– Bruno Wego
I agree with @Brunowego’s position. Try using Angular’s native tools for this, such as
ng-if
.– OnoSendai
Okay, @Brunowego, could you assist me as I should replace jQuery with Angular in this particular case?
– lucasbento
They managed to understand my problem through the simulation in Jsfiddle?
– lucasbento