Question

I have my controller set up like this:

function MyCtrl($scope) {
    $scope.obj = ["MobilePhone",null,"HomePhone"];
}

and im using an ng-repeat:

<div ng-controller="MyCtrl">
     <p ng-repeat="yeah in obj"> {{yeah}}</p>
</div>

and I need to show the empty space from the null value like this:

MobilePhone

HomePhone

but instead im getting this:

MobilePhone
HomePhone

Any help would be nice.

Was it helpful?

Solution

Try:

<p ng-repeat="yeah in obj"> {{yeah || '&nbsp;' }}</p>

Working example: http://jsfiddle.net/63wWe/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top