gpt4 book ai didi

javascript - onclick 中 location.href 中的 AngularJS 变量值未解析

转载 作者:行者123 更新时间:2023-11-29 11:02:52 24 4
gpt4 key购买 nike

在 HTML 中我有一个 Angular 变量叫做

boards.current.url

我可以通过它看到它的值(value)

{{boards.current.url}}

但是我想在 location.href 中使用它的值,如下所示,

<div class="board" onclick="location.href='{{boards.current.url}}'" style="cursor: pointer;">

这是行不通的—— Angular 变量的值

boards.current.url

没有得到解决 - 有任何见解吗?

最佳答案

使用 Angular Directive(指令) ng-click 而不是 onclick

<div class="board" ng-click="location.href='{{boards.current.url}}'" style="cursor: pointer;">

关于javascript - onclick 中 location.href 中的 AngularJS 变量值未解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43920016/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com