Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angular js: ng-min \ ng-max

I using angular js, combined with angular ui, to show modal window in my website. HTML

<script type="text/ng-template" id="myModalContent.html">
    <div class="modal-header text-center">
        <h3 class="modal-title" id="modal-title">Jump to page</h3>
    </div>
    <div class="modal-body text-center" id="modal-body">
        <input type="number" ng-model="info.page" class="text-center" ng-enter="ok()" ng-min="{{info.min}}" ng-max="{{info.max}}" />
        <div>MAX: {{info.max}}</div>
        <div>MIN: {{info.min}}</div>
        <button class="btn btn-primary" type="button" ng-click="ok()" style="margin-top: 20px;">OK</button>
    </div>
</script>

The user have to fill an input number in a range of info.max to info.min.

Here the relevant angular code - Triggering the modal window opening:

function gotoPageDialog(fileNo, current, max) {
    var modalInstance = $uibModal.open({
        templateUrl: 'myModalContent.html',
        controller: 'ModalInstanceCtrl',
        size: 'sm',
        resolve: {
            current_info: function() {
                return {
                    fileNo: fileNo,
                    page: current,
                    max: max,
                    min: 1
                }
            }
        }
    });

    modalInstance.result.then(function(result) {
            //...
        };
    }
}

And the modal window it self:

app.controller('ModalInstanceCtrl', function($scope, $uibModalInstance, current_info) {
    $scope.info = current_info;

    $scope.ok = function() {
        $uibModalInstance.close($scope.info);
    };

    $scope.cancel = function() {
        $uibModalInstance.dismiss('cancel');
    };
});

The result is:

enter image description here

The input value is "-1", What's mean that the ng-min and ng-max range is not working.

What I'm doing wrong?

Thank you.

like image 372
No1Lives4Ever Avatar asked Sep 07 '16 07:09

No1Lives4Ever


2 Answers

Change ng-min and ng-max to

min="{{info.min}}"

max="{{info.max}}"

like image 129
Krupesh Kotecha Avatar answered Sep 23 '22 21:09

Krupesh Kotecha


Change your ng-min and ng-max sintax to

ng-min="{{info.min}}"

ng-max="{{info.max}}"

like image 24
illeb Avatar answered Sep 24 '22 21:09

illeb