【问题标题】:New to Angularjs and Wordpress. Where is the error in this code?Angularjs 和 Wordpress 的新手。这段代码的错误在哪里?
【发布时间】:2014-09-19 10:40:10
【问题描述】:

我正在开发一个 Wordpress 和 Angularjs 项目。

当我加载其中一个页面时,我在 Chrome 开发工具中收到此错误:

Error: [$parse:syntax] Syntax Error: Token '?' not a primary expression at column 60 of the expression [{lineNumbers:showLn, mode:'plaintext', onLoad:configEditor<?if(!$can_write):?>, readOnly:'nocursor'<?endif;?>}] starting at [?if(!$can_write):?>, readOnly:'nocursor'<?endif;?>}].

这是错误所在的代码:

<form class="contenido-evento">
    <textarea ui-codemirror="{lineNumbers:showLn, mode:'plaintext', onLoad:configEditor<?if(!$can_write):?>, readOnly:'nocursor'<?endif;?>}"
              ng-model="evento.texto"></textarea>
</form>

谁能帮我找出问题所在?

【问题讨论】:

  • 调试此问题的一个策略是转到第 60 列的 ?(如错误所示)并弄清楚您打算在那里做什么。
  • 我不明白为什么我对这个问题投了反对票。据我所知,&lt;? 是一种有效的 PHP 语法。但是,它给了我一个语法错误,这就是我问的原因。

标签: javascript php wordpress angularjs


【解决方案1】:

我设法通过在? 符号后添加“php”来解决此问题。像这样:

<textarea ui-codemirror="{lineNumbers:showLn, mode:'plaintext', onLoad:configEditor<?php if(!$can_write):?>, readOnly:'nocursor'<?php endif;?>}"
    >
</textarea>

【讨论】:

  • 所以,short_open_tag 配置在您的环境中的 php.ini 中被关闭。
  • 谢谢runTarm。我不知道这可以在php.ini 文件中配置。
猜你喜欢
  • 2015-07-13
  • 1970-01-01
  • 1970-01-01
  • 2023-03-19
  • 1970-01-01
  • 2012-12-03
  • 1970-01-01
  • 2012-04-17
  • 1970-01-01
相关资源
最近更新 更多