如何在Scala模板中使用AngularJs?
我正在尝试显示数据库中的图像。但是,我不能将角度变量放在Scala模板的如何在Scala模板中使用AngularJs?,angularjs,scala,playframework,Angularjs,Scala,Playframework,我正在尝试显示数据库中的图像。但是,我不能将角度变量放在Scala模板的@符号中 <div class="col-sm-6 col-md-3" ng-repeat="product in products"> <a href="#"> <div class="thumbnail"> <img class="img-responsive" ng-src="@routes.BookStore.getImage(
@
符号中
<div class="col-sm-6 col-md-3" ng-repeat="product in products">
<a href="#">
<div class="thumbnail">
<img class="img-responsive" ng-src="@routes.BookStore.getImage(product.name)">
...
</div>
</a>
</div>
它仍然给了我同样的错误。如何在Scala模板中使用
AngularJs
变量?您不能这很明显-Scala模板在后端处理的时间比到达前端的时间早得多。相反,Angular应用程序应该有一些方法,可以创建一个包含图像路径的字符串,类似于/bookstore/get image/foo.jpg
,然后将路由添加到路由文件中:
您也可以尝试使用,但这不是必需的。我做了与您提到的相同的事情。我有与你的答案相同的路线,我还有
product.name
包含的foo.jpg
。那么,我如何通过传递文件名变量来调用路由呢?在我开始回答时,您不能使用Angular生成的URL
<img class="img-responsive" ng-src="@routes.BookStore.getImage( {{ product.name }} )">
GET /book-store/get-image/:fileName controllers.BookStore.getImage(fileName)