I have some notify message to display, which using difference template by difference notify type.
Now I have make the template into directives, I display the right directive by using ng-switch, like this :
<ul>
<li ng-repeat="notify in notifies | orderBy: 'id'" >
<div ng-switch on="notify.type">
<div ng-switch-when="1">
<span ng-notify-A ng-notify="notify"></span>
</div>
<div ng-switch-when="2">
<span ng-notify-B ng-notify="notify"></span>
</div>
<div ng-switch-when="3">
<span ng-notify-C ng-notify="notify"></span>
</div>
</div>
</li>
</ul>
Yet I really think it can be better, with setting java script logic then output, instead of ng-switch. It should be work with some array to store [type => directive Name ] like this :
array[1]="ng-notify-A";
array[2]="ng-notify-B";
array[3]="ng-notify-C";
I come up to this and don't have idea what's next I can do ... Like I don't know if I can add some logic on directives, or not.
ng-notifyand do some contextual processing depending on the nature of thenotifybinding