ng-show="my.message" is set to true in http success but it doesn't update the view.
Here is my code:
Controller Js:
lgControllers.controller('FormCtrl', function($scope, $http) {
$scope.my = {
message: false
};
$scope.submitForm = function() {
$http({
url: "../saket/ajax.php",
data: "email_id=" + $scope.form.emailaddress + "&category_id=" + cat_num + "&action=subscribe",
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
}
}).success(function(data) {
$scope.my = {
message: true
};
console.log(data); // http is success
console.log($scope.my.message); // gives true
}).error(function(err) {
"ERR", console.log(err)
})
};
});
Index.html:
<div ng-controller="FormCtrl">
<div ng-show="my.message">It worked!</div>
</div>
my.message gives true in console but the div remains hidden in the view.
I can't figure out where the problem is.
Can it be that you are overwriting the message property, and angularjs is loosing the reference?
try just :