angularjs angular js:ng-min \ ng-max

goucqfw6  于 12个月前  发布在  Angular
关注(0)|答案(3)|浏览(109)

我使用angular js,结合angular ui,在我的网站中显示模态窗口。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>

字符串
用户必须填写info.maxinfo.min范围内的输入数字。
此处为相关Angular 代码-触发模态窗口打开:

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) {
            //...
        };
    }
}


和模态窗口它自己:

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');
    };
});


其结果是:
x1c 0d1x的数据
输入值为“-1”,这意味着ng-minng-max范围不工作。
我做错了什么?
谢谢

icnyk63a

icnyk63a1#

ng-minng-max更改为

min="{{info.min}}"
max="{{info.max}}"

字符串

xtfmy6hx

xtfmy6hx2#

将您的ng-minng-max sintax更改为
ng-min="{{info.min}}"
ng-max="{{info.max}}"

thigvfpy

thigvfpy3#

我使用了以下语法:

<input type="number" ng-min="minQuantity" ng-max="maxQuantity">

字符串
其中,minQuantity和maxQuantity是$范围上的属性

相关问题