惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Proofpoint News Feed
宝玉的分享
宝玉的分享
人人都是产品经理
人人都是产品经理
博客园_首页
爱范儿
爱范儿
博客园 - 叶小钗
aimingoo的专栏
aimingoo的专栏
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
阮一峰的网络日志
阮一峰的网络日志
IT之家
IT之家
Microsoft Security Blog
Microsoft Security Blog
Blog — PlanetScale
Blog — PlanetScale
博客园 - 【当耐特】
Y
Y Combinator Blog
量子位
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
The Blog of Author Tim Ferriss
月光博客
月光博客
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
A
About on SuperTechFans

V2EX

我用 AI 写代码,但终端管理反而成了累赘——于是我做了 codux [调研] 各位在公司都用什么 ide 和 agent 写代码? 老运维 share 一个运维平台 看到有公司考核 token 指标,很好奇大家上个月的 AI 账单是多少 GLM-Coding 调用持续报错: z.ai 的 Lite 套餐几乎无法使用,官方 Pro/Max 是否稳定? 现在还有什么渠道可以稳定安全地使用 Claude 吗? 上海漕河泾内推,本组有 2 个 hc,一个后端,一个前端,预算都是 20k 左右,不打卡,氛围好 如果 V2EX 上有一组不永久保存聊天记录(比如只保存 7 天或者 24 小时)的聊天室,那么会开启哪些有用或者有趣的可能? gemini cli 貌似挂了,一直返回 403 第一次在自媒体上赚到钱 收集了最近在使用的低价 GPT, Gemini,邮箱等 AI 会员的小店合集 讨论个大实话:现在企业还在说 AI 编程提效 20%, 30%的,真的太落后,没用懂 AI。因为包括很多前沿公司,已经狂奔到提效 200%-500%的情况 [招聘][远程][币安] 前端/后端/QA/iOS/Android 至少 3 年以上经验 目前有大量 HC 欢迎投递 Chatgpt Pro 用量用不完的可以开这些设置 面试的时候好像遇到钓鱼了,给各位避个坑 cursor 年续费 22 号到期, 自动续费是否还是老的计次套餐呢 被两件破事毁掉的一下午,琐碎的内耗消磨人的精力 使用 Planet 存储 Codex 的会话或者重要信息 如果业务部门领导不要你开发功能,而是要求你教会它用 claude code 开发功能,你会怎么做? 分享一个 MacOS 接绿联 CM818 USB 转 DP 转接器使用感受 我的 HR 朋友 10 年老 Java ,非全大专,大家帮忙看看简历 开源了一个 AI 口语练习工具,音素级发音评分,完全免费可自部署 V2EX 上有哪些你觉得很有趣、印象深刻的妹纸? 字节为啥不出个国内版 Vercel? 有在大马的朋友吗? 问个运营商问题 你们在有领导的公司大群发过的最大胆的消息是什么 公司裁员,目前没有工作。想试试摆摊,做一个移动鲜啤打酒车 我的硬盘 Memblaze Pblaze 5 Linux 下不识别,给 Linux 内核提交了补丁, AI 说有望被合并 只有我一个人觉得 codex 不好用?
新手问个 angular 问题,就是表单数据如何优雅的封装到 model 里
helee9199 · 2025-11-24 · via V2EX

angular 区不太活跃 故移动此区

因不可抗力原因要求使用 angular20 开始学这个,然后有个问题很困扰 ,就是一般每个表单都会有个对应的 model 页面上会用 formControlName 。 然后我们的 model 字段很多 在 component 里就有很多这种代码

 const tubeData: TubeModel = {
      commonParams: this.commonParams,
      tubeInitDate: formatDate(formValue.tubeInitDate, 'yyyy/MM/dd HH:mm'),
      tubeInsertionDate: formatDate(formValue.tubeInsertionDate, 'yyyy/MM/dd HH:mm'),
      anticipatedTubeRemovalDate: formatDate(formValue.anticipatedTubeRemovalDate, 'yyyy/MM/dd'),
      tubeId: formValue.tubeId,
      tubeName: formValue.tubeName,
      tubeGroup: formValue.tubeGroup,
      tubeType: formValue.tubeType,
      tubeMaterial: formValue.tubeMaterial,
      tubeProductNumber: formValue.tubeProductNumber,
      tubeProductNumberOtherValue: formValue.tubeProductNumber || '',
      innerLength: formValue.innerLength,
      innerUnit: 'cm',
      bodyPosition: formValue.bodyPosition,
      bodyPart: formValue.bodyPart,
      tubeLength: formValue.tubeLength,
      tubeUnit: 'cm',
      seqNumber: formValue.seqNumber === '其他' ? formValue.seqNumberOther : formValue.seqNumber,
      drainage: formValue.drainage || 0,
      traits: {
        color: formValue.color,
        colorOther: formValue.colorOther || '',
        nature: formValue.nature,
        natureOther: formValue.natureOther || '',
        flavor: formValue.flavor,
        flavorOther: formValue.flavorOther || '',
      },
    };
以及这种
      this.form.patchValue({
      tubeGroup: tube.tubeGroup,
      tubeId: tube.tubeId,
      tubeInitDate: tube.tubeInitDate ? new Date(tube.tubeInitDate) : null,
      tubeInsertionDate: tube.tubeInsertionDate ? new Date(tube.tubeInsertionDate) : null,
      anticipatedTubeRemovalDate: tube.anticipatedTubeRemovalDate
        ? new Date(tube.anticipatedTubeRemovalDate)
        : null,
      tubeName: tube.tubeName,
      tubeType: tube.tubeType,
      tubeMaterial: tube.tubeMaterial,
      tubeProductNumber: tube.tubeProductNumber,
      innerLength: tube.innerLength,
      bodyPosition: tube.bodyPosition,
      bodyPart: tube.bodyPart,
      tubeLength: tube.tubeLength,
      seqNumber: tube.seqNumber,
      drainage: tube.drainage,
    });
还有 init 的时候这种
      ngOnInit(): void {
    this.form = this.fb.group({
      tubeGroup: [null],
      tubeId: [null],
      tubeInitDate: [null],
      tubeInsertionDate: [null],
      anticipatedTubeRemovalDate: [null],
      tubeName: [null],
      tubeType: [''],
      tubeMaterial: [null],
      tubeProductNumber: [null],
      innerLength: [null],
      bodyPosition: [null],
      bodyPart: [''],
      tubeLength: [null],
      seqNumber: [null],
      seqNumberOther: [''],
      drainage: [null],
      color: [null],
      colorOther: [''],
      flavor: [null],
      flavorOther: [''],
      nature: [null],
      natureOther: [''],
    });

  }

我觉得看着很冗余 字段多了一刷一大片 既然有了 model ,有办法简化这部分吗