angular - 按钮标签中的路由器链接属性不起作用

标签 angular angular-cli

我无法使用放置在按钮标记内的路由器链接属性进行导航。这是我的代码,

<button mat-raised-button color="primary"><a routerLink="/message-inbox">Inbox</a></button>
    <button mat-raised-button color="accent"><a routerLink="/sent">Sent</a></button>
    <a routerLink="/message-compose"><button color="warn">Compose</button></a>

最佳答案

可以申请routerLink直接到按钮。它不一定是 <a元素

<button mat-raised-button color="primary" routerLink="/message-inbox">Inbox</button>

关于angular - 按钮标签中的路由器链接属性不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47652201/

相关文章:

angular - 当运行 "ng serve --watch"时,浏览器如何知道源发生任何变化时何时刷新?

angular - 无法在 app.module 中导入 MatDialogModule

angularjs - 我怎么知道我使用的是哪个 Angular 2 版本?

javascript - 函数未在 HTMLButtonElement.onclick Angular 4 中定义

typescript - 模块 '"angular2/angular 2"' 没有导出成员 'For'

git - 从 Github Angular 4 项目中排除环境文件

angular - 使用 "browser refresh/reload"或 F5 刷新页面时拦截器未执行

Angular 8 CLI : Disable differential loading in development serve

Angular 6/7 "the result of a dependency is an expression"

angular - 我可以使用最新的稳定 TypeScript 还是应该坚持使用 AngularCLI 附带的版本?