[SOLVED] Scope.apply() for rerendering a template?

Hi all!

my example dosnt work. should i use directives and how they work?

Template:

<div ng-show="status == false">Not checked</div>
<div ng-show="status == true">Checked</div>

Part of the controller:

$http.post(url, _postData, config)
.success(function (data, status, headers, config) {
$scope.$apply(function () {
$scope.sendstatus = true;
});
})
.error(function (data, status, header, config) {
$scope.$apply(function () {
$scope.sendstatus = false;
});
});

So if the request give a success the template dosnt change. Any ideas?

Kind regards!

try this (have not checked this myself)

<div ng-show="!sendstatus">Not checked</div>
<div ng-show="sendstatus">Checked</div>

$scope.sendstatus = false;

$http.post(url, _postData, config)
.success(function (data, status, headers, config) {
    $scope.sendstatus = true;
})
.error(function (data, status, header, config) {
    $scope.sendstatus = false;
});

please use code formatting next time :slight_smile:

Works perfect. Thank you :slight_smile: