html - 更改 div 位置运行时间
问题描述
我有一个表单页面,其中包含多个输入字段和表单顶部的下拉字段。
条件是当下拉值更改时,某些字段位置会更改..
示例:
使用下拉值 1 表单将是。
Name ____
Address ____
PAN No ____
Mobile ____
并带有下拉值 2 形式。
Name ____
Mobile ____
Location ____
PAN No ____
链接plnkr
解决方案
您可以尝试与此类似的方法。
声明array
要显示的字段,最初保持该字段为array
空,然后change
根据value
填充array
所需字段的下拉菜单,将您绑定UI
到该动态array
。
就像是 :-
$scope.inMod = ["Noda1", "Noda2" ];
$scope.stack = []; //initially the stack has no items, empty UI
$scope.selectedNoda = ''; //this makes sure nothing show up
$scope.nodaChange = function(value){
if(value=='Noda1') {
$scope.stack = ['Name', 'Address', 'PAN No', 'Mobile'];
}
if(value=='Noda2') {
$scope.stack = ['Name', 'Mobile', 'Location', 'PAN No'];
}
}
array
并迭代UI
<select ng-model="selectedNoda" ng-change="nodaChange(selectedNoda)" ng-options="x for x in inMod">
</select>
<div ng-repeat="item in stack">
<label>{{item}}:</label>
<input id="item" type="text" ng-model="item" />
<br />
</div>
推荐阅读
- gradle - Gradle:覆盖插件中的排除配置
- node.js - 使用 Oauth1 签名的 NodeJS 的 API 调用不起作用
- python - 在 Python 中加密一个可以用 str 加密的字符串来解密
- regex - 正则表达式删除与第二个字符串匹配的行?
- c# - EFCore 框架脚手架覆盖 DBContext 文件
- jquery - 使用 jQuery 管理数据库填充过滤器名称以显示一些投资组合项目
- sql - 基于可变开始日期+天间隔,我需要找到当天之后的下一个日期
- prolog - Prolog问题建模:不同颜色的对象
- jinja2 - 在 saltstack 中使用 jinja 和柱子.get() // 过滤器的工作方式不如预期
- android - Android 无法将应用程序添加到谷歌商店 APK 或 App Bundle 可用于 64 位设备,但它们只有 32 位本机代码