AngularJS在ng-switch-when内更改菜单

时间:2016-11-04 12:55:38

标签: javascript html angularjs

我可以在ng-switch-when中放置一个锚标签(<a>)吗? 这是我的代码:( HERE IS A PREVIEW PLNKR LINK) 我想做这样的事情:

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

    <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.
</div>

这里我有3个菜单,在第二个菜单(JQUERY)上,我给菜单1(ANGULAR)添加了一个链接,但它不起作用...有人可以帮我吗?

非常感谢!!

1 个答案:

答案 0 :(得分:1)

ng-switch创建一个新范围...您需要使用$ parent访问正确的范围来定义选项卡属性:

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

(因为这里没必要,我删除了课程)