3
I have an Ionic app that sends messages. Already helped me, here in the same forum, to make a way that does not allow the user to touch the send button, without having typed anything, so the message does not go blank. Blz, it works cool
<button class="button button-clear button-positive" ng-disabled="msgForm.msg.$invalid && disableButton" ng-click="enviarMsg(mensagem)">Enviar</button>
controller:
$scope.enviarMsg = function (mensagem) {
$scope.disableButton = true;
var dia = moment().format(); //2016-02-16 T 16:05:52-02:00
var diaP = dia.split('T');
var dia = diaP[0];
var horaP = diaP[1];
var horaP2 = horaP.split(':');
var hora = horaP2[0]+':'+horaP2[1];
var enviaMsg = {
mensagem: mensagem,
idUsuario: $window.localStorage.getItem('idUsuario'),
idCep: $window.localStorage.getItem('idCep'),
nome: $window.localStorage.getItem('nome'),
dia: dia,
hora: hora
}
$http.post("http://www.vigilantescomunitarios.com/www/php/enviaMsgLogra.php", enviaMsg).success(function (data){
$scope.disableButton = false;
pegaMsgsLogra();
$scope.mensagem = {
msg: ""
}
});
}
However, as sometimes the message takes time to leave, I would like the button is also disabled and the field, too, until the message is sent. How could I do that? because I’m already using ng-disabled on the button.
http://answall.com/questions/115273/comordisablilitar-campo-e-bot%C3%A3o-em-Angularjs
– DiegoAugusto
Friend, this post that you posted here, I who made and helped me in a part of my doubt. Now the doubt is another.
– GustavoSevero
According to what you described it seems the same thing.. Improve your question a little bit.
– DiegoAugusto
What is your suggestion of question? For they seem the same but it is not kkkk
– GustavoSevero
ng-disabled="msgForm.msg.$invalid && condicaoMensagem"
– DiegoAugusto
Blz! I’m gonna try
– GustavoSevero
Dude, it didn’t work... I’ll put my current code here in the post
– GustavoSevero
Put the entire code where you make the request
– DiegoAugusto