javascript - Angularjs ngSwitch with static nodes? -
how can have common nodes in ngswitch?
<div ng-controller="myctrl"> <div ng-repeat="widget in widgets" ng-switch="" on="widget.foo"> <h1>test</h1> <p ng-switch-when="bar">lorem ipsum</p> <small ng-switch-when="baz">lorem ipsum</small> <footer>common footer</footer> </div> </div>
the switch element renders last child of template. ideas if there better way?
try this:
<div ng-controller="myctrl"> <div ng-repeat="widget in widgets"> <h1>test</h1> <div ng-switch on="widget.foo"> <p ng-switch-when="bar">lorem ipsum</p> <small ng-switch-when="baz">lorem ipsum</small> </div> <footer>common footer</footer> </div> </div>
jsfiddle here.
Comments
Post a Comment