【问题标题】:Why do I get Lexerr:unterminated quote error?为什么我会收到 Lexer: 未终止的报价错误?
【发布时间】:2019-03-04 19:36:15
【问题描述】:

我有以下模板:

<!--Votez pour ce concept de bar:-->
<p ng-show="enabled('http://ballentines.herokuapp.com/{{finalist.slug}}.html') === 'novote'">Not voted</p>

<!-- Vous avez voté pour ce concept de bar-->
<p ng-show="enabled('http://ballentines.herokuapp.com/{{finalist.slug}}.html') === 'thisvote'">
    Voted for this concept
</p>

<!--Vous ne pouvez voter que pour un seul concept de bar -->
<p ng-show="enabled('http://ballentines.herokuapp.com/{{finalist.slug}}.html') === 'othervote'">
    Voted for another concept
</p>

当我尝试运行它时,我得到了

Error: [$parse:lexerr] Lexer Error: Unterminated quote at columns 8-57 ['http://ballentines.herokuapp.com/{{finalist.slug] in expression [enabled('http://ballentines.herokuapp.com/{{finalist.slug].
http://errors.angularjs.org/1.2.11/$parse/lexerr?p0=Unterminated%20quote&p1=s%208-57%20%5B'http%3A%2F%2Fballentines.herokuapp.com%2F%7B%7Bfinalist.slug%5D&p2=enabled('http%3A%2F%2Fballentines.herokuapp.com%2F%7B%7Bfinalist.slug

我做错了什么?

【问题讨论】:

  • 这里有同样的错误。期待答案。
  • fwiw(尽管您看到的可能不是同一个问题)当我在角度属性规范中有一个额外的“=”字符时,我遇到了类似的 Lexer 错误。当我删除额外的“=”时,错误就消失了。
  • 我无法使用此plunker 重现此错误。您是否知道任何其他可能也会影响此的代码?指令、包含等? finalist.slug 的价值是什么?

标签: angularjs


【解决方案1】:

安装 Chrome 的 Angular Batarang 扩展时,我时常会收到此错误消息。它会自动更新,有时会出现错误,有时不会。

为了测试这一点,我只是禁用 Batarang 并刷新应用程序。

【讨论】:

  • 我通过安装AngularJS Batarang (Stable) 扩展解决了这个问题。
  • 是的。 Batarang 不适合我们用于排序的“-columnName”。然而,AngularJS 本身对此非常满意。
【解决方案2】:

ng-show 期望 expression{{ }} 只是 ng-bind 指令的快捷方式。你的情况

<p ng-show="enabled('http://ballentines.herokuapp.com/' + finalist.slug + '.html') === 'novote'">Not voted</p>

应该可以。

【讨论】:

  • 不,不应该:finalist.slug 之前有一个额外的单引号 :-)
猜你喜欢
相关资源
最近更新 更多
热门标签