I have a text field and button to send that text. You are having a small delay , after I click the send button until the message is sent. Then I need to disable the text field and the button until the message is sent and appears on the screen, then enable them again. How can I do this using Angular?
HTML:
<label class="item-input-wrapper">
<input type="text" ng-focus="inputUp()" ng-blur="inputDown()" ng-disabled="!mensagem" ng-model="mensagem.msg" placeholder="Texto" />
</label>
<button class="button button-small" ng-click="enviarMsg(mensagem)">Enviar</button>
controller:
$scope.enviarMsg = function (mensagem) {
//console.log(mensagem);
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){
//console.log(data);
pegaMsgsLogra();
$scope.mensagem = {
msg: ""
}
});
}