【问题标题】:Perform angularjs operation inside value attribute of html input tag在 html 输入标签的 value 属性内执行 angularjs 操作
【发布时间】:2016-06-11 08:32:46
【问题描述】:

我想执行此操作,但 value 属性不起作用

<input name="grand_total" type="text" class="form-control" value="@{{sum(saletemp)*discount1/100 | currency: "&#x9f3"}}" />

<input name="discount" type="text" class="form-control" id="add_payment"  ng-model="discount1"/>

第二个问题 如果我想在提交 html 表单后从 P 标记发送值,我该怎么做以及如何检索该值? 我想将此值 @{{sum(saletemp)*discount1/100 | currency: "&amp;#x9f3"}} 传递给我的控制器,并希望将其存储到我的数据库中。这是代码部分

<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: "&#x9f3"}}</b></p>
      </div>
</div>

【问题讨论】:

  • ?你找到解决方案了吗?
  • @TirthrajBarot 以不同的方式做到了。
  • 我出去旅行.. 我会在 3 天内找到你

标签: html mysql angularjs laravel-5.1


【解决方案1】:

您应该使用 ng-model 而不是处理输入标签的 value 属性...这将为您提供更多的灵活性,可以对其进行几乎任何类型的操作并在控制器中访问它。 .

like ng-model="saletemp" 将在控制器中以 $scope.saletemp 的形式提供给您。如果您想在输入标签值的某些更改上调用函数,您可以简单地调用您将在控制器中定义的 ng-change="functionName()"作为

 $scope.functionName = function(){YOUR FUNCTION DEFINITION}

这是一个小提琴,当您使用ng-model 时,它将允许您将货币放入输入标签中。 http://jsfiddle.net/arunpjohny/wNBAn/

【讨论】:

    猜你喜欢
    • 2015-09-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-24
    • 2017-10-14
    • 1970-01-01
    • 1970-01-01
    • 2015-01-31
    相关资源
    最近更新 更多