Pass variable Angularjs through JS function

Asked

Viewed 707 times

1

I have a dynamic modal in Jquery that is called with the onclick="ShowModal()" is working. However, I want to send values coming from Angularjs and cannot. It sends the code Angularjs {{dado.idUser}}, but not the value 01.

onclick="ShowModal('<?php echo URL.'Usuarios/?form=AlterarSenha&idu={{dado.idUser}}&nomeFunc={{dado.nomeFunc}}'; ?>',300,430)"

I did a test, I just put onclick="ShowModal({{dado.idUser}})" and went to display the source code to see the result and it does not put the value, only the code.

Someone can help me with that. I don’t know much about Angular or Javascript.

  • use the ng-click directive I believe will work

1 answer

1

You can call a Function and take the value using angular.element:

HTML

onclick="exibirModal()"

JS

function exibirModal(){
    var nome = angular.element('#idMeuController').scope().dado.nomeFunc;
    ShowModal(nome);
}

Where idMeuController is the id of the element that has its control.

  • I will study this option, but at first I would have to make a function for each different modal, according to the variables I wanted to pass. I think.

Browser other questions tagged

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