If you just need to display it in the DOM, this should work:
<div ng-controller="appCtrl">
<p>{{ hasClosebtn ? "test" : "sdffffffff" }}</p>
<div>
If you need it stored in $scope.closeBtnText, you can use $watch:
$scope.$watch('hasClosebtn', function(newValue, oldValue) {
$scope.closeBtnText = newValue ? 'test' : 'sdffffffff';
});
To give some insights why that $scope variable does not get updated in the current code, think of this scenario:
app.controller('appCtrl', function($scope) {
$scope.hasClosebtn = true;
$scope.closeBtnText = ($scope.hasClosebtn) ? 'test' : 'sdffffffff';
// $scope.closeBtnText => 'test'
$scope.hasClosebtn = false;
// $scope.closeBtnText => 'test'
});
The flow of the code does not go back to re-evaluate your ternary expression. The detection of the change on $scope.hasClosebtn happens at the $digest cycle.
$scope.$watch.