输入元素的ng-model没有将值传递给方法调用

时间:2018-04-16 13:59:40

标签: javascript angularjs

我有这个html模板:

    <br>
    <input type="number"
           name="input"
           required
           class="form-control input-md"
           ng-model="totalPay"
           placeholder="Amount"
           ng-minlength="1"
           ng-maxlength="3"
           min="1"
           max="150">

<td><select ng-options="reason for reason in refundReasons" required ng-model="chosenReason">
    <option value="">Select refund reason</option>
</select></td>
<br>

<button class="btn btn-primary" ng-click="payDriver(userId, totalPay, chosenReason)">Pay driver</button>

</p>

出于某种原因,无论我如何尝试,我都会获得totalPay == undefined

其他值userIdchosenReason符合预期。

我的控制员:

var opsToolControllers = angular.module('opsToolControllers');

opsToolControllers.controller('payoutCtrl', ['$scope', '$location', 'Util', 'User', 'Payout', function ($scope, $location, Util, User , Payout) {

    $scope.refundReasons = ["1 -- No show compensation", "2 -- Bonus not paid"];
    $scope.userId = null;
    $scope.totalPay = null;

这是我尝试调用的控制器中的方法:

$scope.payDriver = function (userId, total, chosenReason) {
    Payout.payDriver(userId, $scope.totalPay, chosenReason, successCallBack, errorCallBack())
};

arg total == undefined和正文$scope.totalPay == null

0 个答案:

没有答案