Reputation: 39384
I have the following on Angular controller scope model:
$scope.model = {
subscriber: { email: '', name: '' },
notice: { text: '', type: '' }
}
I need to display a P tag whenever notice.text is not empty and add a CSS class equal to notice.type. So I have:
<p class="notice" data-ng-bind="model.notice.text" data-ng-if="model.notice.text != ''"></p>
P tag has always the class "notice". But I need to add the class contained in $scope.model.type if it is defined.
How can I do this?
Side question: Is there a better way to show / hide the P tag instead of using data-ng-if?
Upvotes: 1
Views: 240