0

I have this controller

'use strict';

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;

    function init() {
        $scope.status = null;
        $scope.payouts = null;
        $scope.pending = null;
        $scope.showPayoutsInfo = false;
        $scope.showPendingInfo = false;
    };

    function successCallBack(response) {
        $scope.opStatus = Util.parseError('OK');
        $scope.transactionId = "";
        Util.stopProcessIndication();
    };

    function errorCallBack(response) {
        $scope.status = Util.parseError(response);
        Util.stopProcessIndication();
    };


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

    $scope.userId = $location.search().userId;
    if ($scope.userId) {
        $scope.getUserPayouts($scope.userId);
    }

    $scope.validateTotal = function(obj, total) {
        $scope.totalPay = 150;

        $scope.inputNum.value = parseInt($scope.slider.value);
    };

}]);

and this html

    <input type="number" id="input_total" class="form-control" ng-model="$scope.totalPay" id="totalPay" required ng-change="validateTotal(this, totalPay)">


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

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

</p>

what am i missing as the <input> doesn't do two way binding with the $scope.totalPay

I mean not when I call payDriver(...) and not when the validator override the $scope.totalPay

R. Richards
  • 24,603
  • 10
  • 64
  • 64
Elad Benda
  • 35,076
  • 87
  • 265
  • 471

2 Answers2

1

Juse use totalPay

 <input type="number" id="input_total" class="form-control" ng-model="totalPay" id="totalPay" required ng-change="validateTotal(this, totalPay)">
Sajeetharan
  • 216,225
  • 63
  • 350
  • 396
0

Try this. In your controller declare your totalPay variable like this.

$scope.total = {};
$scope.total.totalPay = null;

Then in your html

<input type="number" id="input_total" class="form-control" ng-model="total.totalPay" id="totalPay" required ng-change="validateTotal(this, totalPay)">
Risalat Zaman
  • 1,189
  • 1
  • 9
  • 19