我正在尝试更新<input type="number">
字段,具体取决于<select>
中所选的选项,以及min=""
和max=""
,但输入字段获取red和empty:ionic将这些类放在标记中:
class="ng-valid-max ng-valid-number ng-dirty ng-invalid ng-invalid-min ng-invalid-required"
输入值类型的console.logs
表示它们确实是数字。
修改:如果我在以下位置注释代码片段://初始化权重和单位字段中的值 那个小虫就消失了......
template.html
<div id="weightdata" class="row">
<div id="weighttext"> <!-- class="col-20 enteryourweighttext"> -->
My weight:
</div>
<input id="weightinput" type="number" name="userweight" min="{{data.minWeight}}" max="{{data.maxWeight}}" ng-model="data.userweight" ng-change="saveUserWeight()" required></input>
<div id="weightunitradios">
<ion-checkbox class="checkboxes" ng-model="data.weightunit" ng-true-value="kg" ng-false-value="lbs" ng-change="saveWeightUnit(); convertWeightInput();">kg</ion-checkbox>
<ion-checkbox class="checkboxes" ng-model="data.weightunit" ng-true-value="lbs" ng-false-value="kg" ng-change="saveWeightUnit(); convertWeightInput();">lbs</ion-checkbox>
</div>
</div>
controllers.js:
.controller('WeightlevelCtrl', function($scope, $ionicPopup, $timeout, sessionService) {
//initialise the values in the weight and unit fields
console.log(sessionService.get('weightunit'))
if (sessionService.get('weightunit')) {
$scope.data.weightunit = sessionService.get('weightunit');
console.log(sessionService.get('weightunit') );
} else {
$scope.data.weightunit = 'kg';
};
if ($scope.data.weightunit === 'kg'){
$scope.data.minWeight="30";
$scope.data.maxWeight="140";
} else {
$scope.data.minWeight="65";
$scope.data.maxWeight="310";
}
if (sessionService.get('userWeight')) {$scope.data.userweight = sessionService.get('userWeight') } else {$scope.data.userweight = 70};
if (sessionService.get('userLevel')) {$scope.data.levelvalue = sessionService.get('userLevel') } else {$scope.data.levelvalue = 5};
if (sessionService.get('weightunit')) {
$scope.data.weightunit = sessionService.get('weightunit');
console.log(sessionService.get('weightunit') );
} else {
$scope.data.weightunit = 'kg';
};
if ($scope.data.weightunit === 'kg'){
$scope.data.minWeight="30";
$scope.data.maxWeight="140";
} else {
$scope.data.minWeight="65";
$scope.data.maxWeight="310";
}
if (sessionService.get('userWeight')) {$scope.data.userweight = sessionService.get('userWeight') } else {$scope.data.userweight = 70};
if (sessionService.get('userLevel')) {$scope.data.levelvalue = sessionService.get('userLevel') } else {$scope.data.levelvalue = 5};
$scope.convertWeightInput = function () {
if ($scope.data.weightunit === 'kg'){
$scope.data.minWeight="30";
$scope.data.maxWeight="140";
$scope.data.userweight = parseFloat(Math.round(lbs2kg($scope.data.userweight)));
console.log(typeof $scope.data.userweight);
console.log($scope.data.userweight);
} else {
$scope.data.minWeight="65";
$scope.data.maxWeight="310";
$scope.data.userweight = parseFloat(Math.round(kg2lbs($scope.data.userweight)));
console.log(typeof $scope.data.userweight);
console.log($scope.data.userweight);
}
}
$scope.saveWeightUnit = function() {
sessionService.persist('weightunit', $scope.data.weightunit);
}
$scope.saveUserWeight = function() {
sessionService.persist('userWeight', $scope.data.userweight);
}
$scope.saveUserLevel = function() {
sessionService.persist('userLevel', $scope.data.levelvalue);
}
})
截图:
答案 0 :(得分:0)
如此处所见https://github.com/angular/angular.js/issues/2404
我们需要使用ng-min
和ng-max
代替min
和max
。
答案 1 :(得分:0)
实际上我不得不将这个过程分成两个函数:
Error using mvnrnd
SIGMA must be a symmetric positive semi-definite matrix.
Error in copularnd
u = normcdf(mvnrnd(zeros(1,d),Rho,n));