I have a "view" page constructed with AngularJS where I display the value of a model as follows:
<span ng-bind="doctor.address || '[Not defined yet]'"></span>
If the value of doctor.address is undefined I correctly get the [Not defined yet] text.
Since this is a "view" page, I know the values won't change while it is displayed, so, I wanted to save some watchers and use the ng-bind once feature:
<span ng-bind="::doctor.address || '[Not defined yet]'"></span>
but if there is a valid an existing value for doctor.address I still get the [Not defined yet] text.
If I use the following:
<span ng-bind="::doctor.address"></span>
I correctly get the doctor address value.
This doesn't work either:
<span ng-bind="::doctor.address">[Not defined yet]</span>
So, how can I define a "default value" when using the ng-bind once feature?
EDIT: this is the actual code with a last test that didn't work:
...
Restangular.one('doctors', params.doctorId).get().then(function(response) {
$scope.doctor = response;
$scope.test = "Hello!!!";
}, function(errorResponse) {
console.log(errorResponse);
});
...
and this is the markup:
<span ng-bind="::test || '[Not defined yet]'"></span>
and still no idea of what might be wrong (the async call would be affecting?)
This is a plunk (forked from the one on Alex Pollan answer) where I can reproduce the issue (I used a custom promise): https://plnkr.co/edit/pjPeTZq8GxaDfvEWk3xV?p=preview
$scope.doctorgets populated viaRestangularand it contains the address. Odd.