我有1个下拉列表,其中包含值(“截止日期”,“终身”,“NA”。这些值来自数据库)。我有2个文本框textbox1和textbox 2.我想要{{1} }(即textbox1
)如果Dropdown值选为“DueDate
”并且已启用如果Dropdown值选为“Due Date
”,则启用textbox2(即TenureDate
)。
Tenure
答案 0 :(得分:1)
(function(angular) {
'use strict';
angular.module('ngrepeatSelect', [])
.controller('ExampleController', ['$scope', function($scope) {
$scope.data = {
model: null,
availableOptions: [
{name: 'DueDate'},
{name: 'TenureDate'},
{name: 'NA'}
]
};
}]);
})(window.angular);
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example</title>
<script src="//code.angularjs.org/snapshot/angular.min.js"></script>
</head>
<body ng-app="ngrepeatSelect">
<div ng-controller="ExampleController">
<form name="myForm">
<label for="repeatSelect"> Repeat select: </label>
<select name="repeatSelect" id="repeatSelect" ng-model="data.model">
<option ng-repeat="option in data.availableOptions" value="{{option.name}}">{{option.name}}</option>
</select>
<input type="textBox1" ng-disabled="data.model != 'DueDate'"/>
<input type="textBox2" ng-disabled="data.model != 'TenureDate'"/>
</form>
<hr>
<tt>model = {{data.model}}</tt><br/>
</div>
</body>
</html>