【问题标题】:weird behavior angularjs & php奇怪的行为angularjs和php
【发布时间】:2016-06-17 08:23:02
【问题描述】:

谁能告诉我为什么返回 false:

if('{{shopController.shop.shop_id}}.xml' == '89.xml')

即使{{shopController.shop.shop_id}} is 89 (string)

我正在尝试

echo nl2br(htmlspecialchars(file_get_contents($xml_file)));

【问题讨论】:

  • 这个 if 语句在什么上下文中?是在 PHP 中吗?它在 Angular 中吗?如果是在 PHP 中,那么 PHP 在服务器上运行,而您的 Angular 代码将在客户端上运行,它就是行不通。
  • 没有足够的信息来给出明智的答案。

标签: javascript php angularjs


【解决方案1】:

你需要使用类似的东西

if($scope.shop_id+'.xml' === '90.xml')

{{}} 只能在模板文件中使用。不在js 文件中。

PS:我认为这是客户端代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-12-11
    • 2019-06-14
    • 1970-01-01
    • 1970-01-01
    • 2020-06-30
    • 2021-03-03
    • 2017-08-29
    相关资源
    最近更新 更多