在angularjs和middleman上处理资产

Handling assets on angularjs and middleman

本文关键字:处理 middleman angularjs      更新时间:2023-09-26

我很难将angularjs集成到我的中间人应用程序中。我正在遵循phonecatApp教程中的angularjs和教程6中关于模板和链接图像的教程。输出很好,但是控制台显示了一个恼人的错误。

GET http://localhost:4567/images/ 404 (Not Found)

现在我读到,当把角表达式直接到图像元素的src属性时,会发生这个问题,所以建议把它放在ng-src指令中,但我正在使用它的助手,它给了我这个错误。下面是我的代码:

= image_tag nil, "ng-src" => asset_path(:images, "{{phone.imageUrl}}")

image_tag助手在任何情况下都添加了src属性(参见http://www.padrinorb.com/api/Padrino/Helpers/AssetTagHelpers.html#image_tag-instance_method,点击'查看源代码'):

# File 'padrino-helpers/lib/padrino-helpers/asset_tag_helpers.rb', line 253
def image_tag(url, options={})
  options.reverse_merge!(:src => image_path(url))
  tag(:img, options)
end

由于image_tag内部只使用tag助手,您可以使用…

= tag :img, "ng-src" => asset_path(:images, "{{phone.imageUrl}}")