javascript - 事件精确路由器链接演示?

标签 javascript angular

angular router文档包含以下有关如何使事件路由器链接准确的代码片段:

The RouterLinkActive directive toggles css classes for active RouterLinks based on the current RouterState. This cascades down through each level of the route tree, so parent and child router links can be active at the same time. To override this behavior, you can bind to the [routerLinkActiveOptions] input binding with the { exact: true } expression. By using { exact: true }, a given RouterLink will only be active if its URL is an exact match to the current URL.

有人有精确路由器链接的演示吗?

最佳答案

在下面的示例中,active-link 类将 仅当 URL 为 /inbox 时才添加,而不是 /inbox/33

<a [routerLink]="/inbox" 
   routerLinkActive="active-link" 
   [routerLinkActiveOptions]="{exact: true}">
    Inbox
</a>

关于javascript - 事件精确路由器链接演示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44526521/

相关文章:

javascript - 如何在 localStorage API HTML5 中保存函数

javascript - Prototype 中 Ajax 请求的默认全局超时是多少?

angular - 如何在所有路由上应用canActivate guard?

javascript - 来自 Angular 1 背景时在 Angular 2 中思考

javascript - Angular 异步数据

javascript - 如何使用 PHP 获取星级小部件的值?

javascript - 绝对中心*上方* div 具有不同大小的内容

angular - 'npm i @auth0/angular-jwt' 中不存在 angular2-jwt 中的 AuthHttp 类

Angular2 模板引用变量和动态更新

c# - 使用 JS 调用 C# 方法