我有两个如下所示的选择框
Coverage.py warning: No data was collected. (no-data-collected)
我的目标是禁用或隐藏其他选择的选项,如果我从<select ng-model="secondCountry" id="secondCountry" required class="form-control" >
<option ng-value="0">Select 2nd Country</option>
<option >india</option>
<option >usa</option>
<option >Japan</option>
</select>
<select ng-model="thridCountry" id="thridCountry" required class="form-control" >
<option ng-value="0">Select 3rd Country</option>
<option >india</option>
<option >usa</option>
<option >Japan</option>
</select>
中选择选项India
,则我first select box
从dont need to select
Option India
。
注意:我使用ng-repeat加载选项
我尝试了second select box
属性,但这会禁用整个选择框。
如何管理此问题?
答案 0 :(得分:4)
您可以通过两种方式管理此方案。
您必须将第二个import path from 'path';
import express from 'express';
import cors from 'cors';
import mongoose from 'mongoose';
import https from 'https';
import fs from 'fs';
import pagesRouter from './pages/pagesRouter';
import apiRouter from './api/api_router';
import dotenv from 'dotenv';
dotenv.config();
//Encryption assests
const privateKey = fs.readFileSync('./app/server/encryption/localhost.key', 'utf8');
const certificate = fs.readFileSync('./app/server/encryption/localhost.crt', 'utf8');
const credentials = {key: privateKey, cert: certificate};
const app = express();
const assets = express.static(path.join(__dirname, '../'));
app.use(cors());
app.use(assets);
//Database connection
const uri = process.env.DB_CONNECTION_STRING;
mongoose.connect(uri, {useNewUrlParser: true});
//Every route with api
app.use('/api', apiRouter);
//Every route that doesn't have api
app.get(/^((?!api).)*$/, pagesRouter);
//https connection
const httpsServer = https.createServer(credentials,app, () => {
console.log('Listening HTTPs')
});
httpsServer.listen(8443);
export default app;
与dropdown
事件绑定,如下所示:
第一
ngChange
第二
您已禁用了在<select ng-model="secondCountry" id="secondCountry" required class="form-control" >
<option ng-value="0">Select 2nd Country</option>
<option>india</option>
<option>usa</option>
<option>Japan</option>
</select>
<select ng-model="thridCountry" id="thridCountry" ng-change="change()" required class="form-control" >
<option ng-value="0">Select 3rd Country</option>
<option>india</option>
<option>usa</option>
<option>Japan</option>
</select>
$scope.change = function() {
if($scope.secondCountry == $scope.thridCountry){
$scope.thridCountry = '0';
}
};
中第一个dropdown
中选择的那些选项。
ngDisabled