在HTML5 / angularjs输入中显示除法计算结果 [英] Display division calculation result in an HTML5 / angularjs input
本文介绍了在HTML5 / angularjs输入中显示除法计算结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我在计算器的禁用输入中有一个问题,计算我在2个不同输入中输入的两个数字的除法结果。
我想在inputDureeAnnee上显示inputMontantGlobalAffaire分区的结果,并把它放在inputMontantAnnual中,但我无法从App.js文件中执行此操作br $>
Index.cshtml:
Hello,
I have a problem in the display in a "disabled" input of the result of calculating division of two numbers that I enter in 2 different inputs.
I want to show the result of the division of inputMontantGlobalAffaire on inputDureeAnnee, and put it in inputMontantAnnual, but I can not do it from the file App.js
Index.cshtml :
<script src="~/ScriptsJS/App.js"></script>
<div ng-app="App" ng-controller="Ctrl">
<form class="form-horizontal" id="supportDemandeForm" name="supportDemandeForm" method="post" ng-submit="validationSupportDemande(supportDemandeForm.$valid)" novalidate>
<fieldset>
<div class="form-group" ng-class="{ 'has-error': supportDemandeForm.inputMontantGlobalAffaire.$touched && supportDemandeForm.inputMontantGlobalAffaire.$invalid }">
<div class="col-lg-10">
<input type="number" class="form-control" id="inputMontantGlobalAffaire" name="inputMontantGlobalAffaire" ng-model="inputMontantGlobalAffaire" pattern="[0-9]+(\\.[0-9][0-9]?)?" required>
</div>
</div>
<div class="form-group" ng-class="{ 'has-error': supportDemandeForm.inputDureeAnnee.$touched && supportDemandeForm.inputDureeAnnee.$invalid }">
<div class="col-lg-10">
<input type="number" class="form-control" id="inputDureeAnnee" name="inputDureeAnnee" placeholder="" ng-model="inputDureeAnnee" ng-keypress="montantAnnuel()" required>
</div>
<div class="col-lg-10">
<input disabled type="number" class="form-control" id="inputMontantAnnuel" name="inputMontantAnnuel" ng-model="inputMontantAnnuel" >
</div>
</div>
</fieldset>
App .js
App.js
///<reference path="../Scripts/angular.min.js" />
///<reference path="../Scripts/angular-route.min.js" />
var App = angular.module('App', ['ngMessages']);
App.controller('Ctrl', ['$scope', Ctrl]);
function Ctrl($scope) {
$scope.montantAnnuel = function () {
if (isNaN(inputMontantAnnuel)) {
inputMontantAnnuel = "";
}
else {
inputMontantAnnuel = inputMontantGlobalAffaire / inputDureeAnnee;
}
};
}
我的尝试:
我尝试了很多东西,但它不起作用
What I have tried:
I tried many things, but it does not work
推荐答案
有效) novalidate >
< ; fieldset >
< div class = form-group ng-class = {'has-error ':supportDemandeForm.inputMontantGlobalAffaire。
valid)" novalidate> <fieldset> <div class="form-group" ng-class="{ 'has-error': supportDemandeForm.inputMontantGlobalAffaire.
touch&& supportDemandeForm.inputMontantGlobalAffaire。
touched && supportDemandeForm.inputMontantGlobalAffaire.
invalid} >
< div class = col-lg-10 >
< 输入 type = number class = form-control id = inputMontantGlobalAffaire name = inputMontantGlobalAffaire ng-model = inputMontantGlobalAffaire pattern = [0-9] +(\\。[0-9] [0-9]? )? 必需 >
< / div >
< / div >
< div class = form-group ng-class = {'has-error':supportDemandeForm.inputDureeAnnee。
invalid }"> <div class="col-lg-10"> <input type="number" class="form-control" id="inputMontantGlobalAffaire" name="inputMontantGlobalAffaire" ng-model="inputMontantGlobalAffaire" pattern="[0-9]+(\\.[0-9][0-9]?)?" required> </div> </div> <div class="form-group" ng-class="{ 'has-error': supportDemandeForm.inputDureeAnnee.
这篇关于在HTML5 / angularjs输入中显示除法计算结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文