Home cannot bind angular js to controller member
Reply: 0

cannot bind angular js to controller member

user2179
1#
user2179 Published in April 21, 2018, 3:23 pm

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

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.301478 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO