View logic data binding?


#1

I’ve got a JSON data set that needs to be sanitized in the view.

For instance if I’m creating a page template with an address; and my data has “street”:“123 fake st”, “street2”:"", “city”:“california”

How might i evaluate if street2 empty, don’t display in my view? (where as other data sets may have street2 available)

I understand that if it’s empty it won’t display, but the extra line break would mess up my view.

<div>
    {{data.street}}<br/>
    {{data.street2}}<br/>
    {{data.city}}
</div>

#2

Try <div ng-if="data">...</div> http://docs.angularjs.org/api/ng/directive/ngIf


#3

awww yiss! that works. Also found ng-show does the same/similar.