How to bind an alert message with the controller? <p>Hi guys I've been experimenting with a simple commenting app with AngularJS and I'm stuck on how to get an alert message popup in the view if a user inputs an empty string into an input field.</p> <p><strong>The HTML view and ng-show logic as below</strong>:</p> <pre><code>&lt;div ng-show="alert===true" class="alert alert-warning alert-dismissible inner" role="alert"&gt; &lt;button type="button" class="close" data-dismiss="alert"&gt;&lt;span aria-hidden="true"&gt;&amp;times; &lt;/span&gt;&lt;span class="sr-only"&gt;Close&lt;/span&gt;&lt;/button&gt; &lt;strong&gt;Warning!&lt;/strong&gt; You did not submit a comment. &lt;/div&gt; </code></pre> <p><strong>The controller view and $scope logic as below</strong>: </p> <pre><code>// pushes data back to Firebase Array $scope.addComment = function(){ if ($scope.newComment.text === ''){ $scope.alert = true; } else { $scope.alert = false; } $scope.comments.$add($scope.newComment); $scope.newComment = {text: '', date: ''}; }; </code></pre> <p>The problem is that although I can bind the alert message logic to the HTML view, the alert message only shows up once and cannot be re-used again if the user types in an empty string again.</p> <p>Should I use a while loop or something for this? Any help would be much appreciated!</p> <p><strong>EDIT:</strong></p> <p>Thanks to meriadec's feedback, I have made a fix using a more simple codebase, as follows.</p> <p><strong>The HTML view and ng-show logic as below</strong>:</p> <pre><code>&lt;div ng-show="alert===true" class="alert alert-warning inner" role="alert"&gt; &lt;button type="button" class="btn" ng-click="alert=false"&gt;&lt;span aria-hidden="true"&gt;&amp;times; &lt;/span&gt;&lt;span class="sr-only"&gt;Close&lt;/span&gt;&lt;/button&gt; &lt;strong&gt;Warning!&lt;/strong&gt; You did not submit a comment. &lt;/div&gt; </code></pre> <p><strong>The controller view and $scope logic as below</strong>: </p> <pre><code>// pushes data back to Firebase Array $scope.addComment = function(){ if ($scope.newComment.text === ''){ return $scope.alert = true; }; $scope.comments.$add($scope.newComment); $scope.newComment = {text: '', date: ''}; }; </code></pre>