Hi,

Well you could have the class definition in a scope function, but i 
personally prefer to maintain visual definitions in the "view".

Maybe i would do it this way:

<ul class="news-list">
    <li data-ng-repeat="news in newsList" class="news"
        data-ng-class="{'Success': newsSuccess , 'Error':newsError, 'Info': 
newsInfo }[news.type]">
        <h5 class="col-sm-12">{{news.content}}</h5>
    </li>
</ul>

Just a change in syntax that seems better to me.

Of course you could have:
 data-ng-class="getClass()"
Where your scope function would basically do the same validations shown 
above.

This is somewhat a matter of personal preference.

Regards,


Segunda-feira, 26 de Maio de 2014 21:56:52 UTC+1, Bretto escreveu:
>
> <ul class="news-list">
>     <li data-ng-repeat="news in newsList" class="news"
>         data-ng-class="{newsSuccess: news.type === 'Success', newsError: 
> news.type === 'Error', newsInfo: news.type === 'Info', newsUpdate: 
> news.type === 'Update', newsCustom: news.type === 'Custom'}">
>         <h5 class="col-sm-12">{{news.content}}</h5>
>     </li>
> </ul>
>
> Could someone tell me what's the best way to manage the assignments of 
> class based on conditions, my current solution works but its ugly... thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to