Angular 在角4中设置组合框值成员
我试图将所选行的值设置为组合框,但只加载输入 这是我的网页的一部分Angular 在角4中设置组合框值成员,angular,typescript,Angular,Typescript,我试图将所选行的值设置为组合框,但只加载输入 这是我的网页的一部分 ` <form class="form-horizontal form-label-left parsleyjs" method="post" data-parsley-priority-enabled="false" novalidate="novalidate"> <fieldset> <div class="form-group row">
` <form class="form-horizontal form-label-left parsleyjs" method="post" data-parsley-priority-enabled="false" novalidate="novalidate">
<fieldset>
<div class="form-group row">
<label class="form-control-label labelName" for="basic-change">
Name
</label>
<div class="inputName">
<input #newRole type="text" id="basic-change" name="basic-change" class="form-control" data-parsley-minlength="4" data-parsley-trigger="change"
maxlength="50" value="{{role.name}}" required="required">
</div>
</div>
<div class="inputName">
<select #newEnv class="form-control" required="required">
<option value="b">Back Office</option>
<option value="c">Casino</option>
<option value="s">Store</option>
</select>
</div>
div class="form-group row">
<label class="form-control-label labelName" for="basic-change">
Description
</label>
<div class="inputName">
<input #newDesc type="text" id="basic-change" name="basic-change" class="form-control" data-parsley-minlength="4" data-parsley-trigger="change"
value="{{role.description}}" required="required">
</div>
</fieldset>
</form>
当我使用与加载输入相同的方式时,
你知道怎么做吗?好吧,只需添加两行,但最终还是行得通, 在组件上,我必须添加以下变量:
options:any=[{value:'b',name:'Back Office},{value:'c',name:'Casino},{value:'s',name:'Store}]代码>
并将其替换为选项标记:
{{p.name}
此.role
中要映射到select
的属性的名称是什么?查看双向数据绑定
export class RolesReplaceComponent implements OnInit {
@ViewChild('modal') public modal: ModalDirective;
mensaje: string;
error: boolean;
role;
private isLoading = false;
constructor(
private route: ActivatedRoute,
private router: Router,
private svrRole: RoleService,
private http: Http,
private trans: TranslateService, ) {
this.error = false;
}
ngOnInit(): void {
jQuery('.parsleyjs').parsley();
this.isLoading = true;
this.svrRole = new RoleService(this.http);
this.route.params
.subscribe(
param => {
this.svrRole.getById(param['id'], null)
.subscribe(
resp => {
console.log(resp);
this.role = resp.data.data;
console.log(this.role);
this.isLoading = false;
console.log('Que sucedio?');
},
error => console.log("Error on edit-roles-services ", error));
}
);
}
}