Can someone familiar with angular explain how you would would make a special case '<li>There are no names in the list</li>'? It is obvious to me how to do it with ember, but non-obvious in angular.
Can someone familiar with angular explain how you would would make a special case '<li>There are no names in the list</li>'? It is obvious to me how to do it with ember, but non-obvious in angular.
<ul>
<li ng-repeat="name in names">{{name}}</li>
<li ng-show="!names.length">There are no names in the list</li>
</ul> <div ng-switch="names.length">
<ul ng-switch-when="0">
<li>There are no names in the list.</li>
</ul>
<ul ng-switch-default>
<li ng-repeat="name in names">{{name}}</li>
</ul>
</div>
Either way you end up with an ugly dom.It isn't "allergic to conditionals". It just drives the logic elsewhere to keep the presentation layer looking as clean as possible to the developer so that you can either focus on the view (template) or the controller or model.
I will. That seems dumb.
Why are conditionals not allowed in presentation layer but repetition is ?
Personally I like the sort of middle-ground approach that Handlebars [1] has, I'm fine with basic 'truthy/existence' type checks, but will avoid templating languages that allow 'any old code'.
I think this sort of discipline (picking a deliberately restrictive library) is probably more useful for teams than individuals (who are capable of limiting their own conditional crazy).
<ul>
<li ng-repeat="name in names">{{name}}</li>
<li ui-if="!names.length">There are no names in the list</li>
</ul>
: http://angular-ui.github.com/#directives-if