【问题标题】:Embed Angular expression in CakePHP html helper在 CakePHP html helper 中嵌入 Angular 表达式
【发布时间】:2015-01-19 06:38:27
【问题描述】:

我想像这样在 html 助手中嵌入 angularjs 表达式。

<td><?php

echo $this->html->link(_('{{row.Document.name}}'), array('controller' => 'documents', 'action' => 'edit', '_({{row.Document.id}})'));
?>
</td>

在这段代码中,它能够正确获取名称参数,但不能正确获取 id,只是想知道如何修复它?

谢谢。

【问题讨论】:

    标签: javascript angularjs cakephp html-helper


    【解决方案1】:

    你不能,因为它会对'_({{row.Document.id}})' this 进行 URL 编码。

    不要使用帮助器或扩展帮助器并使用如下代码重载方法:

    $url = Router::url($url);
    foreach ($options['unescapedParams'] as $param) {
        $url .= $param;
    }
    

    并通过选项传递您不想逃脱的参数。我根本不会使用助手。我的经验是,我通常有很多 Angular 特定的东西,认为使用表单的帮助器(以任何方式完全由 Angular 处理)最终会得到一个包含所有 Angular 属性的巨大 $options 数组。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-16
      • 2015-05-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多