javascript - AngularJS 在 ng-switch-when 中更改菜单

标签 javascript html angularjs

我可以在 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/

相关文章:

javascript - Angular 如何解析模块中定义的 Controller ?

angularjs - 当我查看 Source 时,如何让 CKEditor 更新我的后备数据对象?

javascript - jQuery .css() 函数和位置 : fixed table 出现问题

javascript - 每 5 秒更换一次背景图片

javascript - 如何使用 JavaScript 获取选择标签上的选定值?

javascript - 导出 React 组件

php - 意外的其他情况(T_ELSE)

html - 为什么盒子阴影会被下面的图形元素剪切和隐藏?

javascript - 使用 AngularJS 路由的 ASP.NET 5 路由

javascript - 我正在尝试选择一个正在使用的元素 :