angular - 绑定角度形式选择选项不起作用
问题描述
我正在尝试使用以下代码正式绑定选择类型选项:
fieldGroup: [
{
key: 'TimeOffTypeID',
type: 'select',
className: 'flex-40 padding-10',
templateOptions: {
label: 'نوع مرخصی',
placeholder: 'نوع مرخصی',
required: true,
options: this.getTimeoffType,
valueProp: 'TimeOffTypeID',
labelProp: 'TimeOffTypeName',
},
和
types$: BehaviorSubject<any[]> = new BehaviorSubject<any[]>([]);
public get getTimeoffType(): Observable<any[]> {
return this.types$.asObservable();
}
和数据服务
getTimeoffTypes() {
this.base
.get(
Controller.TIMEOFFTYPE,
{
TimeOffTypeID: 0,
},
Actions.SEARCH
)
.subscribe(({ result }) => {
console.log(result)
this.types$.next(result);
})
}
结果有我的数据,但此数据未绑定到表单选择选项
解决方案
我遇到了同样的问题,没有显示选项。下面突出显示的代码有助于解决它;templateOptions : { label : "Gender.", labelProp : "name", valueProp : "value", options : [ { "name" : "Male", "value" : "male" }, { "name" : "Female ", "value" : "female" }, { "name" : "Others", "value" : "others" } ],注意:我使用的是 Formly Material
推荐阅读
- java - ObjectMapper 无法正确反序列化作为 AMQP 消息体接收的 json
- mysql - aurora mysql 从 s3 加载指定文件扩展名
- html - HTML:如何通过空格而不是逗号更改输入类型 =“datetime-local”的日期和时间之间的分隔符?
- angular - 如何通过将多个提供程序设置到被访问的同一路由以向用户显示值来从多个 get 调用中检索值?
- sql - 使用 group by 子句选择最旧的 HABTM 记录
- python - 如何以 GEOTIFF 格式保存图像?
- node.js - 简历解析器的节点js问题
- python - 模型导入的 Django Gunicorn Thread 问题
- html - 添加新值后我无法更新表格
- swift - 使用 ui 测试点击 WKWebview 内容