I am experiencing trouble with ng-show. To specify my problem; I have a system where I want to create a user. When you do this, I want the system to generate a box with a return message - specific for .success and .error. I have created to boxes for both cases, however none of these show up when they're supposed to be set to true.
Here is my code.
Html.
<div ng-controller="SignupController as ctrl" >
<div class="alert alert-success" ng-show="ctrl.booleanSuccess">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<div>{{ctrl.feedbackSuccessMessage}}</div>
</div>
<div class="alert alert-warning" ng-show="ctrl.feedbackErrorMessage">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<div>{{ctrl.feedbackErrorMessage}}</div>
</div>
</div>
Javascript.
angular.module('myApp.signup', [])
.controller('SignupController', ["$http", function ($http) {
var self = this;
self.booleanSuccess = false;
self.feedbackSuccessMessage = null;
self.feedbackErrorMessage = null;
//Dette sker, når signup-knappen klikkes (ng-click)
self.signupButton = function () {
var username = self.username;
var password = self.password;
$http.post('http://localhost:8080/MomondoProjectServer/api/flightinfo/createUser/' + username + '/' + password)
.success(function (response, status, headers, config) {
self.username = "";
self.password = "";
console.log(response);
self.booleanSuccess = true;
self.feedbackSuccessMessage = response.info + response.username;
}).error(function (response, status, headers, config) {
self.feedbackErrorMessage = "Failed to create user: '" + self.username + "'. Please try again.";
console.log(self.feedbackErrorMessage);
});
};
}]);