How to display/hide, individually, replicated div in Angularjs, using jQuery?

Asked

Viewed 244 times

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 = '';  
};

inserir a descrição da imagem aqui

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/

  • 2

    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.

  • 1

    I agree with @Brunowego’s position. Try using Angular’s native tools for this, such as ng-if.

  • Okay, @Brunowego, could you assist me as I should replace jQuery with Angular in this particular case?

  • They managed to understand my problem through the simulation in Jsfiddle?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.