我可以在 ng-switch-when 中放置 anchor 标记 ( <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) 的链接,但它不起作用...有人可以帮助我吗?
非常感谢!!
最佳答案
ng-switch 创建一个新范围...您需要使用 $parent 访问正确的范围来定义选项卡属性:
<a class="col-md-1 menu" ng-click="$parent.tab='Angular'"><b>Angular</b></a>
(我删除了该类,因为这里不需要它)
关于javascript - AngularJS 在 ng-switch-when 中更改菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40423244/