Learner Learner - 7 months ago 35
AngularJS Question

default text when the input is empty in angular for label while binding

I have this piece of code that is working fine and displays the data as per received from controller into the binding. However, I tried to make server data as string.empty and I was expecting this default text "Your name" would appear, and it is not. I want the default text to be shown if server returns empty string.

<label for="name" class="label-proj" ng-bind="ctrl.name">Your name</label>


You could do the following:

<label for="name" class="label-proj">{{ctrl.name || "Your name"}}</label>