Vitor Takara Vitor Takara - 1 year ago 91
HTML Question

AngularJS Changing menu's inside ng-switch-when

Can i put a inside a ng-switch-when?
Here is my code: ( HERE IS A PREVIEW PLNKR LINK)
i want to do something like this:

<div ng-switch-when="Jquery">

<a class="col-md-1 menu" ng-class="{active: tab == 'Angular'}" ng-click="tab='Angular'"><b>Angular</b></a>

<br /> jQuery is a cross-platform JavaScript library designed to simplify the client-side scripting of HTML. jQuery is the most popular JavaScript library in use today, with installation on 65% of the top 10 million highest-trafficked sites on the
Web. jQuery is free, open-source software licensed under the MIT License.

Here i have 3 menus, and on second menu (JQUERY), i put a link to menu 1 (ANGULAR), but it does not work... Can anyone help me please?

Thanks a lot!!

Answer Source

ng-switch creates a new scope... you need to use $parent to access the correct scope to define the tab attribute:

<a class="col-md-1 menu" ng-click="$'Angular'"><b>Angular</b></a>

(I removed the class because it was unnecessary here)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download