AngularJS 和 Play-Bootstrap:如何在@b3.submit 中包含 ng-click?
AngularJS and Play-Bootstrap: How to include a ng-click within @b3.submit?
我正在使用 Scala-Play 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
。我希望它可以作为键值对简单地传递到 Map 中,即 <button type="@buttonType" @toHtmlArgs(innerArgsMap)>@text</button>
see here.
所以我只能选择像这样回到计划HTML:
<button type="submit" class="btn btn-danger" ng-click="runInSampleSimulation()">
<span class="glyphicon glyphicon-cog"></span> Run Simulation
</button>
有没有办法将 ng-click
连接到 b3?
我决定通过更改 form
而不是 submit
按钮并使用 ng-submit
来实现此目的。
显然没有开箱即用的解决方案。尽管我所希望的是符号通过,但出于某种原因,破折号 -
是模板的非法符号。因此这会产生错误:
@b3.form(routes.Simulation.computeInSample, 'ng-submit -> "runInSampleSimulation()") {
所以我把 form template 修改成这样的自定义 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/')">
我正在使用 Scala-Play 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
。我希望它可以作为键值对简单地传递到 Map 中,即 <button type="@buttonType" @toHtmlArgs(innerArgsMap)>@text</button>
see here.
所以我只能选择像这样回到计划HTML:
<button type="submit" class="btn btn-danger" ng-click="runInSampleSimulation()">
<span class="glyphicon glyphicon-cog"></span> Run Simulation
</button>
有没有办法将 ng-click
连接到 b3?
我决定通过更改 form
而不是 submit
按钮并使用 ng-submit
来实现此目的。
显然没有开箱即用的解决方案。尽管我所希望的是符号通过,但出于某种原因,破折号 -
是模板的非法符号。因此这会产生错误:
@b3.form(routes.Simulation.computeInSample, 'ng-submit -> "runInSampleSimulation()") {
所以我把 form template 修改成这样的自定义 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/')">