我正在使用Scala 2.5.10、Play-Bootstrap和AngularJS 1.x,我需要从AngularJS处理一个表单提交。然后我试着:
@b3.submit('class -> "btn btn-danger",
'ng-click -> "runInSampleSimulation()") {
<span class="glyphicon glyphicon-cog"></span> Run Simulation
}但是ng-click没有被识别出来。我希望它能作为键值对(即<button type="@buttonType" @toHtmlArgs(innerArgsMap)>@text</button> 请看这里 )简单地传递到Map中。
因此,我只能选择回到下面这样的HTML计划:
<button type="submit" class="btn btn-danger" ng-click="runInSampleSimulation()">
<span class="glyphicon glyphicon-cog"></span> Run Simulation
</button>有办法将ng-click与b3挂钩吗?
发布于 2017-03-21 12:15:41
我决定通过更改form而不是submit按钮和使用ng-submit来实现这一点。
显然没什么解决办法。虽然我所希望的是符号是经过的,但由于某种原因,破折号-是模板的非法符号。因此,这将产生一个错误:
@b3.form(routes.Simulation.computeInSample, 'ng-submit -> "runInSampleSimulation()") {因此,我将表格模板修改为一个自定义b3/ngform.scala.html,如下所示:
@(action: Call, args: (Symbol, Any)*)(body: => Html)(implicit fc: b3.B3FieldConstructor)
<form method="@action.method" ng-submit="@bs.Args.get(args, 'ngsubmit)('@action.toString')"
class="@fc.formClass @bs.Args.get(args, 'class)"
@toHtmlArgs(bs.Args.remove(bs.Args.remove(bs.Args.inner(args, 'role -> "form"), 'ngsubmit), 'class).toMap)>
@body
</form>然后我可以这样用:
@b3.ngform(routes.Simulation.computeInSample, 'ngsubmit -> "runInSampleSimulation") {生成我想要的东西:
<form class="form-horizontal ng-pristine ng-valid"
role="form" method="GET" ng-submit="runInSampleSimulation('/simulation/in/')">https://stackoverflow.com/questions/42924263
复制相似问题