我想执行此操作,但值属性不起作用
<input name="grand_total" type="text" class="form-control" value="@{{sum(saletemp)*discount1/100 | currency: "৳"}}" />
<input name="discount" type="text" class="form-control" id="add_payment" ng-model="discount1"/>
第二个问题
如果我想在提交 html 表单后从 P 标签发送值,我该怎么做以及如何检索该值?
我想传递这个值 @{{sum(saletemp)*discount1/100 | currency: "৳"}}
到我的 Controller 并想将它存储到我的数据库中。这是代码部分
<div class="form-group">
<label for="grand_total" class="col-sm-4 control-label">Discount</label>
<div class="col-sm-8">
<p class="form-control-static" ><b>@{{sum(saletemp)*discount1/100 | currency: "৳"}}</b></p>
</div>
</div>
最佳答案
您应该使用 ng-model 而不是处理输入标签的值属性...这将为您提供更多的灵 active ,可以对其进行几乎任何类型的操作并在 Controller 中访问它。 .
like ng-model="saletemp"
将在 Controller 中以 $scope.saletemp 的形式提供给您。如果您想在输入标签值发生某些变化时调用函数,您可以简单地调用 ng-change="functionName()"
,您将在 Controller 中将其定义为
$scope.functionName = function(){YOUR FUNCTION DEFINITION}
这是一个 fiddle ,它允许您在使用 ng-model
时将货币放入输入标签中。 http://jsfiddle.net/arunpjohny/wNBAn/
关于html - 在 html 输入标签的值属性内执行 angularjs 操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37761676/