Let's say I have the following menu structure:
<li class="dropdown"><img role="button" class="dropdown-toggle" data-toggle="dropdown" ng-src="{{avatarUrl}}" />
<ul class="dropdown-menu pull-right" role="menu">
<li ng-hide="user"><a ng-click="openLoginDialog()">Login</a></li>
<li ng-show="user"><a ng-click="logout()">Logout</a></li>
</ul>
</li>
I get the correct menu, but because I'm using ng-show/ng-hide, when I change user = false; programmatically in the controller, the login menu appears. I get why this is happening, but I'm not sure what approach to take when using Angular to prevent it. I tried an ng-repeat:
<li class="dropdown"><img role="button" class="dropdown-toggle" data-toggle="dropdown" ng-src="{{avatarUrl}}" />
<ul class="dropdown-menu pull-right" role="menu">
<li ng-repeat="action in actions"><a ng-click="{{action.command}}">{{action.name}}</li>
</ul>
</li>
with:
$scope.actions = [ {
name : "Login",
command : "openLoginDialog()"
}, {
name : "Logout",
command : "logout()"
} ];
But with that strategy, nothing happens with I click the menu item. I'm not sure what the appropriate Angular approach is to what I'm sure is a pedestrian use case.