Ich benutze eckige js, kombiniert mit eckigen ui, um modale Fenster in meiner Website zu zeigen. Mein HTML-Code ist:eckig js: ng-min ng-max
<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>
Die Nutzer haben eine Eingangsnummer in einem Bereich von info.max
-info.min
zu füllen.
Hier den entsprechenden Winkelcode - Auslösen die modale Fensteröffnung:
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)
{
//...
};
}
Und das modale Fenster, um es selbst:
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');
};
});
Das Ergebnis ist:
Der Eingabewert ist "-1", was bedeutet, dass der ng-min
und ng-max
Bereich funktioniert nicht.
Was mache ich falsch?
Vielen Dank.
Ich dachte nicht, dass ng-min/ng-max die HTML5-Validierung anwendet? Überprüfen Sie Ihr '$ form' -Objekt und ich würde mir vorstellen, dass es' $ form. $ Valid' als false zurückgibt. –