【问题标题】:how json data into pug template (mongoose)如何将 json 数据转换为哈巴狗模板(猫鼬)
【发布时间】:2018-04-08 23:29:00
【问题描述】:

我正在尝试使用 Angular mongo 和节点(咖啡脚本和猫鼬)开发一个网站。我从 mongo db 获得了一些数据库值,但我需要将数据显示到 pug 模板引擎中

这里是代码

    init: =>
  @Sign
    .find()
    .then (result) =>

      @scope.sign = result.data
    .catch (err) =>
      console.log err

@scope.sign 是 Json 对象 .. 我需要显示从 Json 对象到哈巴狗的一列元素(“产品名称”).. 有人请帮帮我

【问题讨论】:

  • JSON 是什么格式?你能举一个 JSON 的例子吗?
  • { _id: 59f2fcbca65e3f39a309473f, createdAt: 2017-10-27T09:30:36.357Z, updatedAt: 2017-10-27T09:34:48.828Z, name: 'machan peru madhure', __v: 0 , priceunit: 'USD', price: '20000', holdtime: '90', slot: '9', address: '位置或地址', resolution: '920px', width: '100', height: '100' }
  • 使用:result.data中的每个产品>>>>p= product.name

标签: angularjs node.js mongoose coffeescript pug


【解决方案1】:

使用iteration 循环遍历数据。

each product in result.data
    div(class="product-item")
        p= product.name

【讨论】:

  • @scope.sign= result.data 是否正确..??? result.data 正在返回一个 json
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-07-08
  • 1970-01-01
  • 1970-01-01
  • 2017-11-27
相关资源
最近更新 更多