How to display message in AngularJS? [closed]

1

I'm working with angular and need to add a message on the screen when pressing the check code button. An error message or success.

Angle Controller

angular.module().controller(){ 
        vm.validarProtocolo = function(){          
            //exibir mensagem na tela
        };
}

Html Code

<input type="text" name="protocolo" ng-model="brSafe.protocolo">
<button ng-click="validarProtocolo()">Validar Protocolo</button>
    
asked by anonymous 09.02.2017 / 19:06

1 answer

4

In a simple way, making a function display a message:

var app = angular.module('root', []);
app.controller('myCtrl', function($scope) {
    $scope.message = "";
    
    $scope.validarProtocolo = function(){     
        $scope.message = "TESTE";
    };
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script><divng-app="root" ng-controller="myCtrl">
  <p ng-if="message">{{message}}</p>
  <button ng-click="validarProtocolo()">TESTE</button>
</div>
    
09.02.2017 / 19:17