{"id":52668,"date":"2024-12-03T13:30:59","date_gmt":"2024-12-03T05:30:59","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52668\/"},"modified":"2024-12-03T13:30:59","modified_gmt":"2024-12-03T05:30:59","slug":"%e6%8e%a2%e7%b4%a2%e8%a7%92%e5%ba%a6%e5%bd%a2%e5%bc%8f%ef%bc%9a%e4%bf%a1%e5%8f%b7%e7%9a%84%e6%96%b0%e6%9b%bf%e4%bb%a3%e6%96%b9%e6%a1%88-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52668\/","title":{"rendered":"\u63a2\u7d22\u89d2\u5ea6\u5f62\u5f0f\uff1a\u4fe1\u53f7\u7684\u65b0\u66ff\u4ee3\u65b9\u6848"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u63a2\u7d22\u89d2\u5ea6\u5f62\u5f0f\uff1a\u4fe1\u53f7\u7684\u65b0\u66ff\u4ee3\u65b9\u6848<\/h1>\n<p><span style=\"cursor: pointer\"><i><\/i>\u6536\u85cf<\/span>    <\/p>\n<p><span style=\"font-size: 15px\">\u5b66\u4e60\u77e5\u8bc6\u8981\u5584\u4e8e\u601d\u8003\uff0c\u601d\u8003\uff0c\u518d\u601d\u8003\uff01\u4eca\u5929\u7c73\u4e91\u5c0f\u7f16\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u63a2\u7d22\u89d2\u5ea6\u5f62\u5f0f\uff1a\u4fe1\u53f7\u7684\u65b0\u66ff\u4ee3\u65b9\u6848\u300b<\/span>\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u5305\u542b<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60\u6216\u51c6\u5907\u5b66\u4e60<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\uff0c\u5c31\u90fd\u4e0d\u8981\u9519\u8fc7\u672c\u6587\u5566~\u8ba9\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff0c\u80fd\u5e2e\u52a9\u5230\u4f60\u5c31\u66f4\u597d\u4e86\uff01<\/span><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241122\/173225920767402d87cc578.jpg\" class=\"aligncenter\" title=\"\u63a2\u7d22\u89d2\u5ea6\u5f62\u5f0f\uff1a\u4fe1\u53f7\u7684\u65b0\u66ff\u4ee3\u65b9\u6848\u63d2\u56fe\" alt=\"\u63a2\u7d22\u89d2\u5ea6\u5f62\u5f0f\uff1a\u4fe1\u53f7\u7684\u65b0\u66ff\u4ee3\u65b9\u6848\u63d2\u56fe\" \/><\/p>\n<h2> \u63a2\u7d22\u89d2\u5ea6\u5f62\u5f0f\uff1a\u4fe1\u53f7\u7684\u65b0\u66ff\u4ee3\u65b9\u6848 <\/h2>\n<p>\u5728 angular \u7684\u4e16\u754c\u4e2d\uff0c\u65e0\u8bba\u60a8\u662f\u5728\u5236\u4f5c\u7b80\u5355\u7684\u767b\u5f55\u9875\u9762\u8fd8\u662f\u66f4\u590d\u6742\u7684\u7528\u6237\u914d\u7f6e\u6587\u4ef6\u754c\u9762\uff0c\u8868\u5355\u5bf9\u4e8e\u7528\u6237\u4ea4\u4e92\u90fd\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002 angular \u4f20\u7edf\u4e0a\u63d0\u4f9b\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\uff1a<strong>\u6a21\u677f\u9a71\u52a8\u8868\u5355<\/strong>\u548c<strong>\u53cd\u5e94\u5f0f\u8868\u5355<\/strong>\u3002\u5728\u6211\u4e4b\u524d\u7684 angular \u53cd\u5e94\u5f0f\u8868\u5355\u7cfb\u5217\u4e2d\uff0c\u6211\u63a2\u7d22\u4e86\u5982\u4f55\u5229\u7528\u53cd\u5e94\u5f0f\u8868\u5355\u7684\u5f3a\u5927\u529f\u80fd\u6765\u7ba1\u7406\u590d\u6742\u903b\u8f91\u3001\u521b\u5efa\u52a8\u6001\u8868\u5355\u4ee5\u53ca\u6784\u5efa\u81ea\u5b9a\u4e49\u8868\u5355\u63a7\u4ef6\u3002<\/p>\n<p>\u7528\u4e8e\u7ba1\u7406\u53cd\u5e94\u6027\u7684\u65b0\u5de5\u5177 &#8211; <strong>\u4fe1\u53f7<\/strong> &#8211; \u5df2\u5728 angular \u7248\u672c 16 \u4e2d\u5f15\u5165\uff0c\u6b64\u540e\u4e00\u76f4\u662f angular \u7ef4\u62a4\u4eba\u5458\u5173\u6ce8\u7684\u7126\u70b9\uff0c\u5e76\u5728\u7248\u672c 17 \u4e2d\u53d8\u5f97\u7a33\u5b9a\u3002\u4fe1\u53f7\u5141\u8bb8\u60a8\u5904\u7406\u72b6\u6001\u66f4\u6539\u58f0\u660e\u6027\u5730\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4ee4\u4eba\u5174\u594b\u7684\u66ff\u4ee3\u65b9\u6848\uff0c\u5c06\u6a21\u677f\u9a71\u52a8\u8868\u5355\u7684\u7b80\u5355\u6027\u4e0e\u53cd\u5e94\u8868\u5355\u7684\u5f3a\u5927\u53cd\u5e94\u6027\u7ed3\u5408\u8d77\u6765\u3002\u672c\u6587\u5c06\u7814\u7a76\u4fe1\u53f7\u5982\u4f55\u4e3a angular \u4e2d\u7684\u7b80\u5355\u548c\u590d\u6742\u5f62\u5f0f\u6dfb\u52a0\u53cd\u5e94\u6027\u3002<\/p>\n<h2> \u56de\u987e\uff1a\u89d2\u5ea6\u5f62\u5f0f\u65b9\u6cd5 <\/h2>\n<p>\u5728\u6df1\u5165\u63a2\u8ba8\u4f7f\u7528\u4fe1\u53f7\u589e\u5f3a\u6a21\u677f\u9a71\u52a8\u8868\u5355\u7684\u4e3b\u9898\u4e4b\u524d\uff0c\u8ba9\u6211\u4eec\u5feb\u901f\u56de\u987e\u4e00\u4e0b angular \u7684\u4f20\u7edf\u8868\u5355\u65b9\u6cd5\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u6a21\u677f\u9a71\u52a8\u8868\u5355<\/strong>\uff1a\u4f7f\u7528 ngmodel \u7b49\u6307\u4ee4\u76f4\u63a5\u5728 html \u6a21\u677f\u4e2d\u5b9a\u4e49\uff0c\u8fd9\u4e9b\u8868\u5355\u6613\u4e8e\u8bbe\u7f6e\uff0c\u975e\u5e38\u9002\u5408\u7b80\u5355\u8868\u5355\u3002\u4f46\u662f\uff0c\u5b83\u4eec\u53ef\u80fd\u65e0\u6cd5\u63d0\u4f9b\u66f4\u590d\u6742\u573a\u666f\u6240\u9700\u7684\u7ec6\u7c92\u5ea6\u63a7\u5236\u3002<\/p>\n<p>\u8fd9\u662f\u6a21\u677f\u9a71\u52a8\u8868\u5355\u7684\u6700\u5c0f\u793a\u4f8b\uff1a<\/p>\n<pre>&lt;form (ngsubmit)=\"onsubmit()\"&gt;\n  &lt;label for=\"name\"&gt;name:&lt;\/label&gt;\n  &lt;input id=\"name\" [(ngmodel)]=\"name\" name=\"name\"&gt;\n  &lt;button type=\"submit\"&gt;submit&lt;\/button&gt;\n&lt;\/form&gt;\n<\/pre>\n<\/li>\n<\/ol>\n<pre>```typescript\nimport { component } from '@angular\/core';\n\n@component({\n  selector: 'app-root',\n  templateurl: '.\/app.component.html'\n})\nexport class appcomponent {\n  name = '';\n\n  onsubmit() {\n    console.log(this.name);\n  }\n}\n```\n<\/pre>\n<ol>\n<li>\n<p><strong>\u53cd\u5e94\u5f0f\u8868\u5355<\/strong>\uff1a\u4f7f\u7528 angular \u7684 formgroup\u3001formcontrol \u548c formarray \u7c7b\u5728\u7ec4\u4ef6\u7c7b\u4e2d\u4ee5\u7f16\u7a0b\u65b9\u5f0f\u8fdb\u884c\u7ba1\u7406\uff1b\u53cd\u5e94\u5f0f\u8868\u5355\u63d0\u4f9b\u5bf9\u8868\u5355\u72b6\u6001\u548c\u9a8c\u8bc1\u7684\u7cbe\u7ec6\u63a7\u5236\u3002\u6b63\u5982\u6211\u4e4b\u524d\u5173\u4e8e angular reactive forms \u7684\u6587\u7ae0\u6240\u8ba8\u8bba\u7684\u90a3\u6837\uff0c\u8fd9\u79cd\u65b9\u6cd5\u975e\u5e38\u9002\u5408\u590d\u6742\u7684\u8868\u5355\u3002<\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u53cd\u5e94\u5f0f\u5f62\u5f0f\u7684\u6700\u5c0f\u793a\u4f8b\uff1a<\/p>\n<pre>import { component } from '@angular\/core';\nimport { formgroup, formcontrol } from '@angular\/forms';\n\n@component({\n  selector: 'app-root',\n  templateurl: '.\/app.component.html'\n})\nexport class appcomponent {\n  form = new formgroup({\n    name: new formcontrol('')\n  });\n\n  onsubmit() {\n    console.log(this.form.value);\n  }\n}\n<\/pre>\n<\/li>\n<\/ol>\n<pre>```html\n&lt;form [formgroup]=\"form\" (ngsubmit)=\"onsubmit()\"&gt;\n  &lt;label for=\"name\"&gt;name:&lt;\/label&gt;\n  &lt;input id=\"name\" formcontrolname=\"name\"&gt;\n  &lt;button type=\"submit\"&gt;submit&lt;\/button&gt;\n&lt;\/form&gt;\n```\n<\/pre>\n<h2> \u5f15\u5165\u4fe1\u53f7\u4f5c\u4e3a\u5904\u7406\u8868\u5355\u53cd\u5e94\u6027\u7684\u65b0\u65b9\u6cd5 <\/h2>\n<p>\u968f\u7740 angular 16 \u7684\u53d1\u5e03\uff0c\u4fe1\u53f7\u5df2\u7ecf\u6210\u4e3a\u7ba1\u7406\u53cd\u5e94\u6027\u7684\u65b0\u65b9\u5f0f\u3002\u4fe1\u53f7\u63d0\u4f9b\u4e86\u4e00\u79cd\u58f0\u660e\u5f0f\u7684\u72b6\u6001\u7ba1\u7406\u65b9\u6cd5\uff0c\u4f7f\u60a8\u7684\u4ee3\u7801\u66f4\u53ef\u9884\u6d4b\u4e14\u66f4\u6613\u4e8e\u7406\u89e3\u3002\u5f53\u5e94\u7528\u4e8e\u8868\u5355\u65f6\uff0c\u4fe1\u53f7\u53ef\u4ee5\u589e\u5f3a\u6a21\u677f\u9a71\u52a8\u8868\u5355\u7684\u7b80\u5355\u6027\uff0c\u540c\u65f6\u63d0\u4f9b\u901a\u5e38\u4e0e\u53cd\u5e94\u6027\u8868\u5355\u76f8\u5173\u7684\u53cd\u5e94\u6027\u548c\u63a7\u5236\u3002<\/p>\n<p>\u8ba9\u6211\u4eec\u63a2\u7d22\u5982\u4f55\u5728\u7b80\u5355\u548c\u590d\u6742\u7684\u5f62\u5f0f\u573a\u666f\u4e2d\u4f7f\u7528\u4fe1\u53f7\u3002<\/p>\n<h3> \u793a\u4f8b 1\uff1a\u5e26\u6709\u4fe1\u53f7\u7684\u7b80\u5355\u6a21\u677f\u9a71\u52a8\u8868\u5355 <\/h3>\n<p>\u8003\u8651\u4e00\u4e2a\u57fa\u672c\u7684\u767b\u5f55\u8868\u5355\u3002\u901a\u5e38\uff0c\u8fd9\u5c06\u4f7f\u7528\u6a21\u677f\u9a71\u52a8\u7684\u8868\u5355\u6765\u5b9e\u73b0\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>&lt;!-- login.component.html --&gt;\n&lt;form name=\"form\" (ngsubmit)=\"onsubmit()\"&gt;\n  &lt;label for=\"email\"&gt;e-mail&lt;\/label&gt;\n  &lt;input type=\"email\" id=\"email\" [(ngmodel)]=\"email\" required email \/&gt;\n  &lt;label for=\"password\"&gt;password&lt;\/label&gt;\n  &lt;input type=\"password\" id=\"password\" [(ngmodel)]=\"password\" required \/&gt;\n  &lt;button type=\"submit\"&gt;login!&lt;\/button&gt;\n&lt;\/form&gt;\n<\/pre>\n<pre>\/\/ login.component.ts\nimport { component } from \"@angular\/core\";\n\n@component({\n  selector: \"app-login\",\n  templateurl: \".\/login.component.html\",\n})\nexport class logincomponent {\n  public email: string = \"\";\n  public password: string = \"\";\n\n  onsubmit() {\n    console.log(\"form submitted\", { email: this.email, password: this.password });\n  }\n}\n<\/pre>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u7b80\u5355\u7684\u8868\u5355\uff0c\u4f46\u662f\u901a\u8fc7\u5f15\u5165\u4fe1\u53f7\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u6dfb\u52a0\u53cd\u5e94\u529f\u80fd\u7684\u540c\u65f6\u4fdd\u6301\u7b80\u5355\u6027\uff1a<\/p>\n<pre>\/\/ login.component.ts\nimport { component, computed, signal } from \"@angular\/core\";\nimport { formsmodule } from \"@angular\/forms\";\n\n@component({\n  selector: \"app-login\",\n  standalone: true,\n  templateurl: \".\/login.component.html\",\n  imports: [formsmodule],\n})\nexport class logincomponent {\n  \/\/ define signals for form fields\n  public email = signal(\"\");\n  public password = signal(\"\"); \/\/ define a computed signal for the form value\n\n  public formvalue = computed(() =&gt; {\n    return {\n      email: this.email(),\n      password: this.password(),\n    };\n  });\n\n  public isformvalid = computed(() =&gt; {\n    return this.email().length &gt; 0 &amp;&amp; this.password().length &gt; 0;\n  });\n\n  onsubmit() {\n    console.log(\"form submitted\", this.formvalue());\n  }\n}\n<\/pre>\n<pre>&lt;!-- login.component.html --&gt;\n&lt;form name=\"form\" (ngsubmit)=\"onsubmit()\"&gt;\n  &lt;label for=\"email\"&gt;e-mail&lt;\/label&gt;\n  &lt;input type=\"email\" id=\"email\" name=\"email\" [(ngmodel)]=\"email\" required email \/&gt;\n  &lt;label for=\"password\"&gt;password&lt;\/label&gt;\n  &lt;input type=\"password\" name=\"password\" id=\"password\" [(ngmodel)]=\"password\" required \/&gt;\n  &lt;button type=\"submit\"&gt;login!&lt;\/button&gt;\n&lt;\/form&gt;\n<\/pre>\n<p>\u5728\u6b64\u793a\u4f8b\u4e2d\uff0c\u8868\u5355\u5b57\u6bb5\u88ab\u5b9a\u4e49\u4e3a\u4fe1\u53f7\uff0c\u5141\u8bb8\u5728\u8868\u5355\u72b6\u6001\u53d1\u751f\u53d8\u5316\u65f6\u8fdb\u884c\u53cd\u5e94\u5f0f\u66f4\u65b0\u3002 formvalue \u4fe1\u53f7\u63d0\u4f9b\u53cd\u6620\u8868\u5355\u5f53\u524d\u72b6\u6001\u7684\u8ba1\u7b97\u503c\u3002\u8fd9\u79cd\u65b9\u6cd5\u63d0\u4f9b\u4e86\u4e00\u79cd\u66f4\u5177\u58f0\u660e\u6027\u7684\u65b9\u5f0f\u6765\u7ba1\u7406\u8868\u5355\u72b6\u6001\u548c\u53cd\u5e94\u6027\uff0c\u5c06\u6a21\u677f\u9a71\u52a8\u8868\u5355\u7684\u7b80\u5355\u6027\u4e0e\u4fe1\u53f7\u7684\u5f3a\u5927\u529f\u80fd\u7ed3\u5408\u8d77\u6765\u3002<\/p>\n<p>\u60a8\u53ef\u80fd\u4f1a\u60f3\u5c06\u8868\u5355\u76f4\u63a5\u5b9a\u4e49\u4e3a\u4fe1\u53f7\u5185\u7684\u5bf9\u8c61\u3002\u867d\u7136\u8fd9\u79cd\u65b9\u6cd5\u53ef\u80fd\u770b\u8d77\u6765\u66f4\u7b80\u6d01\uff0c\u4f46\u5728\u5404\u4e2a\u5b57\u6bb5\u4e2d\u8f93\u5165\u5185\u5bb9\u5e76\u4e0d\u4f1a\u8c03\u5ea6\u53cd\u5e94\u6027\u66f4\u65b0\uff0c\u8fd9\u901a\u5e38\u4f1a\u7834\u574f\u4ea4\u6613\u3002\u4e0b\u9762\u662f\u4e00\u4e2a stackblitz \u793a\u4f8b\uff0c\u5176\u4e2d\u4e00\u4e2a\u7ec4\u4ef6\u9047\u5230\u4e86\u6b64\u7c7b\u95ee\u9898\uff1a<\/p>\n<p>\u56e0\u6b64\uff0c\u5982\u679c\u60a8\u60f3\u5bf9\u8868\u5355\u5b57\u6bb5\u4e2d\u7684\u66f4\u6539\u505a\u51fa\u53cd\u5e94\uff0c\u6700\u597d\u5c06\u6bcf\u4e2a\u5b57\u6bb5\u5b9a\u4e49\u4e3a\u5355\u72ec\u7684\u4fe1\u53f7\u3002\u901a\u8fc7\u5c06\u6bcf\u4e2a\u8868\u5355\u5b57\u6bb5\u5b9a\u4e49\u4e3a\u5355\u72ec\u7684\u4fe1\u53f7\uff0c\u60a8\u53ef\u4ee5\u786e\u4fdd\u5bf9\u5404\u4e2a\u5b57\u6bb5\u7684\u66f4\u6539\u6b63\u786e\u89e6\u53d1\u53cd\u5e94\u6027\u66f4\u65b0\u3002 <\/p>\n<h3> \u793a\u4f8b 2\uff1a\u5e26\u6709\u4fe1\u53f7\u7684\u590d\u6742\u5f62\u5f0f <\/h3>\n<p>\u60a8\u53ef\u80fd\u770b\u4e0d\u5230\u5bf9\u7b80\u5355\u8868\u5355\uff08\u5982\u4e0a\u9762\u7684\u767b\u5f55\u8868\u5355\uff09\u4f7f\u7528\u4fe1\u53f7\u7684\u597d\u5904\uff0c\u4f46\u5728\u5904\u7406\u66f4\u590d\u6742\u7684\u8868\u5355\u65f6\u5b83\u4eec\u771f\u6b63\u53d1\u6325\u4f5c\u7528\u3002\u8ba9\u6211\u4eec\u63a2\u8ba8\u4e00\u4e2a\u66f4\u590d\u6742\u7684\u573a\u666f &#8211; \u4e00\u4e2a\u7528\u6237\u4e2a\u4eba\u8d44\u6599\u8868\u5355\uff0c\u5176\u4e2d\u5305\u542b\u540d\u5b57\u3001\u59d3\u6c0f\u3001\u7535\u5b50\u90ae\u4ef6\u3001\u7535\u8bdd\u53f7\u7801\u548c\u5730\u5740\u7b49\u5b57\u6bb5\u3002 phonenumbers \u5b57\u6bb5\u662f\u52a8\u6001\u7684\uff0c\u5141\u8bb8\u7528\u6237\u6839\u636e\u9700\u8981\u6dfb\u52a0\u6216\u5220\u9664\u7535\u8bdd\u53f7\u7801\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u5982\u4f55\u4f7f\u7528\u4fe1\u53f7\u5b9a\u4e49\u6b64\u5f62\u5f0f\uff1a<\/p>\n<pre>\/\/ user-profile.component.ts\nimport { jsonpipe } from \"@angular\/common\";\nimport { component, computed, signal } from \"@angular\/core\";\nimport { formsmodule, validators } from \"@angular\/forms\";\n\n@component({\n  standalone: true,\n  selector: \"app-user-profile\",\n  templateurl: \".\/user-profile.component.html\",\n  styleurls: [\".\/user-profile.component.scss\"],\n  imports: [formsmodule, jsonpipe],\n})\nexport class userprofilecomponent {\n  public firstname = signal(\"\");\n  public lastname = signal(\"\");\n  public email = signal(\"\"); \n  \/\/ we need to use a signal for the phone numbers, so we get reactivity when typing in the input fields\n  public phonenumbers = signal([signal(\"\")]);\n  public street = signal(\"\");\n  public city = signal(\"\");\n  public state = signal(\"\");\n  public zip = signal(\"\");\n\n  public formvalue = computed(() =&gt; {\n    return {\n      firstname: this.firstname(),\n      lastname: this.lastname(),\n      email: this.email(), \/\/ we need to do a little mapping here, so we get the actual value for the phone numbers\n      phonenumbers: this.phonenumbers().map((phonenumber) =&gt; phonenumber()),\n      address: {\n        street: this.street(),\n        city: this.city(),\n        state: this.state(),\n        zip: this.zip(),\n      },\n    };\n  });\n\n  public formvalid = computed(() =&gt; {\n    const { firstname, lastname, email, phonenumbers, address } = this.formvalue(); \/\/ regex taken from the angular email validator\n\n    const email_regexp = \/^(?=.{1,254}$)(?=.{1,64}@)[a-za-z0-9!#$%&amp;'*+\/=?^_`{|}~-]+(?:\\.[a-za-z0-9!#$%&amp;'*+\/=?^_`{|}~-]+)*@[a-za-z0-9](?:[a-za-z0-9-]{0,61}[a-za-z0-9])?(?:\\.[a-za-z0-9](?:[a-za-z0-9-]{0,61}[a-za-z0-9])?)*$\/;\n    const isemailformatvalid = email_regexp.test(email);\n\n    return (\n      firstname.length &gt; 0 &amp;&amp;\n      lastname.length &gt; 0 &amp;&amp;\n      email.length &gt; 0 &amp;&amp;\n      isemailformatvalid &amp;&amp;\n      phonenumbers.length &gt; 0 &amp;&amp; \/\/ check if all phone numbers are valid\n      phonenumbers.every((phonenumber) =&gt; phonenumber.length &gt; 0) &amp;&amp;\n      address.street.length &gt; 0 &amp;&amp;\n      address.city.length &gt; 0 &amp;&amp;\n      address.state.length &gt; 0 &amp;&amp;\n      address.zip.length &gt; 0\n    );\n  });\n\n  addphonenumber() {\n    this.phonenumbers.update((phonenumbers) =&gt; {\n      phonenumbers.push(signal(\"\"));\n      return [...phonenumbers];\n    });\n  }\n\n  removephonenumber(index: number) {\n    this.phonenumbers.update((phonenumbers) =&gt; {\n      phonenumbers.splice(index, 1);\n      return [...phonenumbers];\n    });\n  }\n}\n<\/pre>\n<blockquote>\n<p>\u8bf7\u6ce8\u610f\uff0cphonenumbers \u5b57\u6bb5\u88ab\u5b9a\u4e49\u4e3a\u4fe1\u53f7\u6570\u7ec4\u4e2d\u7684\u4e00\u4e2a\u4fe1\u53f7\u3002\u8fd9\u79cd\u7ed3\u6784\u4f7f\u6211\u4eec\u80fd\u591f\u8ddf\u8e2a\u5404\u4e2a\u7535\u8bdd\u53f7\u7801\u7684\u66f4\u6539\u5e76\u53cd\u5e94\u6027\u5730\u66f4\u65b0\u8868\u5355\u72b6\u6001\u3002 addphonenumber \u548cremovephonenumber \u65b9\u6cd5\u66f4\u65b0phonenumbers \u4fe1\u53f7\u6570\u7ec4\uff0c\u89e6\u53d1\u8868\u5355\u4e2d\u7684\u53cd\u5e94\u6027\u66f4\u65b0\u3002<\/p>\n<\/blockquote>\n<pre>&lt;!-- user-profile.component.html --&gt;\n&lt;form class=\"form\"&gt;\n  &lt;label for=\"firstName\"&gt;First Name&lt;\/label&gt; &lt;input type=\"text\" id=\"firstName\" name=\"firstName\" [(ngModel)]=\"firstName\" required \/&gt;\n\n  &lt;label for=\"lastName\"&gt;Last Name&lt;\/label&gt; &lt;input type=\"text\" id=\"lastName\" name=\"lastName\" [(ngModel)]=\"lastName\" required \/&gt;\n\n  &lt;label for=\"email\"&gt;Email&lt;\/label&gt; &lt;input type=\"email\" id=\"email\" name=\"emailAddress\" [(ngModel)]=\"email\" required email \/&gt;\n\n  &lt;div id=\"phoneNumbers\"&gt;\n    &lt;label&gt;Phone Numbers&lt;\/label&gt; @for (phone of phoneNumbers(); track i; let i = $index) {\n    &lt;div&gt;&lt;input type=\"tel\" name=\"phoneNumbers-{{ i }}\" [(ngModel)]=\"phone\" required \/&gt; &lt;button type=\"button\" (click)=\"removePhoneNumber(i)\"&gt;Remove&lt;\/button&gt;&lt;\/div&gt;\n    } &lt;button type=\"button\" (click)=\"addPhoneNumber()\"&gt;Add Phone Number&lt;\/button&gt;\n  &lt;\/div&gt;\n\n  &lt;label for=\"street\"&gt;Street&lt;\/label&gt; &lt;input type=\"text\" id=\"street\" name=\"street\" [(ngModel)]=\"street\" required \/&gt;\n\n  &lt;label for=\"city\"&gt;City&lt;\/label&gt; &lt;input type=\"text\" id=\"city\" name=\"city\" [(ngModel)]=\"city\" required \/&gt;\n\n  &lt;label for=\"state\"&gt;State&lt;\/label&gt; &lt;input type=\"text\" id=\"state\" name=\"state\" [(ngModel)]=\"state\" required \/&gt;\n\n  &lt;label for=\"zip\"&gt;ZIP Code&lt;\/label&gt; &lt;input type=\"text\" id=\"zip\" name=\"zip\" [(ngModel)]=\"zip\" required \/&gt;\n\n  @if(!formValid()) {\n  &lt;div class=\"message message--error\"&gt;Form is invalid!&lt;\/div&gt;\n  } @else {\n  &lt;div class=\"message message--success\"&gt;Form is valid!&lt;\/div&gt;\n  }\n  &lt;pre&gt;\n    {{ formValue() | json }}\n  &lt;\/pre&gt;\n&lt;\/form&gt;\n<\/pre>\n<blockquote>\n<p>\u5728\u6a21\u677f\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528phonenumbers\u4fe1\u53f7\u6570\u7ec4\u6765\u52a8\u6001\u6e32\u67d3\u7535\u8bdd\u53f7\u7801\u8f93\u5165\u5b57\u6bb5\u3002 addphonenumber \u548cremovephonenumber \u65b9\u6cd5\u5141\u8bb8\u7528\u6237\u53cd\u5e94\u6027\u5730\u6dfb\u52a0\u6216\u5220\u9664\u7535\u8bdd\u53f7\u7801\uff0c\u4ece\u800c\u66f4\u65b0\u8868\u5355\u72b6\u6001\u3002\u8bf7\u6ce8\u610f track \u51fd\u6570\u7684\u7528\u6cd5\uff0c\u8fd9\u662f\u786e\u4fdd ngfor \u6307\u4ee4\u6b63\u786e\u8ddf\u8e2aphonenumbers \u6570\u7ec4\u66f4\u6539\u6240\u5fc5\u9700\u7684\u3002<\/p>\n<\/blockquote>\n<p>\u8fd9\u662f\u590d\u6742\u8868\u5355\u793a\u4f8b\u7684 stackblitz \u6f14\u793a\uff0c\u4f9b\u60a8\u8bd5\u7528\uff1a<\/p>\n<h3> \u4f7f\u7528\u4fe1\u53f7\u9a8c\u8bc1\u8868\u5355 <\/h3>\n<p>\u9a8c\u8bc1\u5bf9\u4e8e\u4efb\u4f55\u8868\u5355\u90fd\u81f3\u5173\u91cd\u8981\uff0c\u786e\u4fdd\u7528\u6237\u8f93\u5165\u5728\u63d0\u4ea4\u4e4b\u524d\u6ee1\u8db3\u6240\u9700\u7684\u6807\u51c6\u3002\u4f7f\u7528\u4fe1\u53f7\uff0c\u53ef\u4ee5\u4ee5\u53cd\u5e94\u6027\u548c\u58f0\u660e\u6027\u7684\u65b9\u5f0f\u5904\u7406\u9a8c\u8bc1\u3002\u5728\u4e0a\u9762\u7684\u590d\u6742\u8868\u5355\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5b9e\u73b0\u4e86\u4e00\u4e2a\u540d\u4e3a formvalid \u7684\u8ba1\u7b97\u4fe1\u53f7\uff0c\u5b83\u68c0\u67e5\u6240\u6709\u5b57\u6bb5\u662f\u5426\u6ee1\u8db3\u7279\u5b9a\u7684\u9a8c\u8bc1\u6807\u51c6\u3002<\/p>\n<p>\u53ef\u4ee5\u8f7b\u677e\u81ea\u5b9a\u4e49\u9a8c\u8bc1\u903b\u8f91\u4ee5\u9002\u5e94\u4e0d\u540c\u7684\u89c4\u5219\uff0c\u4f8b\u5982\u68c0\u67e5\u6709\u6548\u7684\u7535\u5b50\u90ae\u4ef6\u683c\u5f0f\u6216\u786e\u4fdd\u586b\u5199\u6240\u6709\u5fc5\u586b\u5b57\u6bb5\u3002\u4f7f\u7528\u4fe1\u53f7\u8fdb\u884c\u9a8c\u8bc1\u53ef\u4ee5\u8ba9\u60a8\u521b\u5efa\u66f4\u591a\u53ef\u7ef4\u62a4\u548c\u53ef\u6d4b\u8bd5\u7684\u4ee3\u7801\uff0c\u56e0\u4e3a\u9a8c\u8bc1\u89c4\u5219\u88ab\u660e\u786e\u5b9a\u4e49\u5e76\u81ea\u52a8\u5bf9\u8868\u5355\u5b57\u6bb5\u4e2d\u7684\u66f4\u6539\u505a\u51fa\u53cd\u5e94\u3002\u5b83\u751a\u81f3\u53ef\u4ee5\u88ab\u62bd\u8c61\u4e3a\u4e00\u4e2a\u5355\u72ec\u7684\u5b9e\u7528\u7a0b\u5e8f\uff0c\u4ee5\u4f7f\u5176\u53ef\u4ee5\u5728\u4e0d\u540c\u5f62\u5f0f\u4e2d\u91cd\u7528\u3002<\/p>\n<p>\u5728\u590d\u6742\u8868\u5355\u793a\u4f8b\u4e2d\uff0cformvalid \u4fe1\u53f7\u53ef\u786e\u4fdd\u586b\u5199\u6240\u6709\u5fc5\u586b\u5b57\u6bb5\u5e76\u9a8c\u8bc1\u7535\u5b50\u90ae\u4ef6\u548c\u7535\u8bdd\u53f7\u7801\u683c\u5f0f\u3002<\/p>\n<p>\u8fd9\u79cd\u9a8c\u8bc1\u65b9\u6cd5\u6709\u70b9\u7b80\u5355\uff0c\u9700\u8981\u66f4\u597d\u5730\u8fde\u63a5\u5230\u5b9e\u9645\u7684\u8868\u5355\u5b57\u6bb5\u3002\u867d\u7136\u5b83\u9002\u7528\u4e8e\u8bb8\u591a\u7528\u4f8b\uff0c\u4f46\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u7b49\u5230 angular \u4e2d\u6dfb\u52a0\u663e\u5f0f\u201c\u4fe1\u53f7\u5f62\u5f0f\u201d\u652f\u6301\u3002 tim deschryver \u5f00\u59cb\u5b9e\u73b0\u4e00\u4e9b\u56f4\u7ed5\u4fe1\u53f7\u5f62\u5f0f\u7684\u62bd\u8c61\uff0c\u5305\u62ec\u9a8c\u8bc1\uff0c\u5e76\u5199\u4e86\u4e00\u7bc7\u5173\u4e8e\u5b83\u7684\u6587\u7ae0\u3002\u8ba9\u6211\u4eec\u770b\u770b\u5c06\u6765 angular \u4e2d\u662f\u5426\u4f1a\u6dfb\u52a0\u8fd9\u6837\u7684\u4e1c\u897f\u3002<\/p>\n<h3> \u4e3a\u4ec0\u4e48\u4f7f\u7528\u89d2\u5ea6\u5f62\u5f0f\u7684\u4fe1\u53f7\uff1f <\/h3>\n<p>angular \u4e2d\u4fe1\u53f7\u7684\u91c7\u7528\u63d0\u4f9b\u4e86\u4e00\u79cd\u5f3a\u5927\u7684\u65b0\u65b9\u6cd5\u6765\u7ba1\u7406\u8868\u5355\u72b6\u6001\u548c\u53cd\u5e94\u6027\u3002\u4fe1\u53f7\u63d0\u4f9b\u4e86\u4e00\u79cd\u7075\u6d3b\u7684\u58f0\u660e\u6027\u65b9\u6cd5\uff0c\u53ef\u4ee5\u901a\u8fc7\u7ed3\u5408\u6a21\u677f\u9a71\u52a8\u8868\u5355\u548c\u53cd\u5e94\u5f0f\u8868\u5355\u7684\u4f18\u52bf\u6765\u7b80\u5316\u590d\u6742\u7684\u8868\u5355\u5904\u7406\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528 angular \u5f62\u5f0f\u7684\u4fe1\u53f7\u7684\u4e00\u4e9b\u4e3b\u8981\u597d\u5904\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u58f0\u660e\u5f0f\u72b6\u6001\u7ba1\u7406<\/strong>\uff1a\u4fe1\u53f7\u5141\u8bb8\u60a8\u4ee5\u58f0\u660e\u65b9\u5f0f\u5b9a\u4e49\u8868\u5355\u5b57\u6bb5\u548c\u8ba1\u7b97\u503c\uff0c\u4f7f\u60a8\u7684\u4ee3\u7801\u66f4\u53ef\u9884\u6d4b\u4e14\u66f4\u6613\u4e8e\u7406\u89e3\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u53cd\u5e94\u6027<\/strong>\uff1a\u4fe1\u53f7\u4e3a\u8868\u5355\u5b57\u6bb5\u63d0\u4f9b\u53cd\u5e94\u6027\u66f4\u65b0\uff0c\u786e\u4fdd\u8868\u5355\u72b6\u6001\u7684\u66f4\u6539\u81ea\u52a8\u89e6\u53d1\u53cd\u5e94\u6027\u66f4\u65b0\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u7c92\u5ea6\u63a7\u5236<\/strong>\uff1a\u4fe1\u53f7\u5141\u8bb8\u60a8\u5728\u7c92\u5ea6\u7ea7\u522b\u5b9a\u4e49\u8868\u5355\u5b57\u6bb5\uff0c\u4ece\u800c\u5b9e\u73b0\u5bf9\u8868\u5355\u72b6\u6001\u548c\u9a8c\u8bc1\u7684\u7ec6\u7c92\u5ea6\u63a7\u5236\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u52a8\u6001\u8868\u5355<\/strong>\uff1a\u4fe1\u53f7\u53ef\u7528\u4e8e\u521b\u5efa\u5e26\u6709\u53ef\u52a8\u6001\u6dfb\u52a0\u6216\u5220\u9664\u5b57\u6bb5\u7684\u52a8\u6001\u8868\u5355\uff0c\u63d0\u4f9b\u7075\u6d3b\u7684\u65b9\u5f0f\u6765\u5904\u7406\u590d\u6742\u7684\u8868\u5355\u573a\u666f\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u7b80\u5355\u6027<\/strong>\uff1a\u4e0e\u4f20\u7edf\u7684\u53cd\u5e94\u5f0f\u8868\u5355\u76f8\u6bd4\uff0c\u4fe1\u53f7\u53ef\u4ee5\u63d0\u4f9b\u66f4\u7b80\u5355\u3001\u66f4\u7b80\u6d01\u7684\u65b9\u5f0f\u6765\u7ba1\u7406\u8868\u5355\u72b6\u6001\uff0c\u4f7f\u6784\u5efa\u548c\u7ef4\u62a4\u590d\u6742\u8868\u5355\u53d8\u5f97\u66f4\u5bb9\u6613\u3002<\/p>\n<\/li>\n<\/ol>\n<h3> \u7ed3\u8bba <\/h3>\n<p>\u5728\u6211\u4e4b\u524d\u7684\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u63a2\u7d22\u4e86 angular \u53cd\u5e94\u5f0f\u8868\u5355\u7684\u5f3a\u5927\u529f\u80fd\uff0c\u4ece\u52a8\u6001\u8868\u5355\u6784\u5efa\u5230\u81ea\u5b9a\u4e49\u8868\u5355\u63a7\u4ef6\u3002\u968f\u7740\u4fe1\u53f7\u7684\u5f15\u5165\uff0cangular \u5f00\u53d1\u4eba\u5458\u62e5\u6709\u4e86\u4e00\u79cd\u65b0\u5de5\u5177\uff0c\u5b83\u5c06\u6a21\u677f\u9a71\u52a8\u8868\u5355\u7684\u7b80\u5355\u6027\u4e0e\u53cd\u5e94\u5f0f\u8868\u5355\u7684\u53cd\u5e94\u6027\u878d\u4e3a\u4e00\u4f53\u3002<\/p>\n<p>\u867d\u7136\u8bb8\u591a\u7528\u4f8b\u90fd\u9700\u8981\u53cd\u5e94\u5f0f\u8868\u5355\uff0c\u4f46\u4fe1\u53f7\u4e3a\u9700\u8981\u66f4\u76f4\u63a5\u3001\u58f0\u660e\u6027\u65b9\u6cd5\u7684 angular \u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u8868\u5355\u72b6\u6001\u7ba1\u7406\u63d0\u4f9b\u4e86\u4e00\u79cd\u5168\u65b0\u3001\u5f3a\u5927\u7684\u66ff\u4ee3\u65b9\u6848\u3002\u968f\u7740 angular \u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u5c1d\u8bd5\u8fd9\u4e9b\u65b0\u529f\u80fd\u5c06\u5e2e\u52a9\u60a8\u6784\u5efa\u66f4\u6613\u4e8e\u7ef4\u62a4\u3001\u6027\u80fd\u66f4\u9ad8\u7684\u5e94\u7528\u7a0b\u5e8f\u3002<\/p>\n<p>\u7f16\u7801\u6109\u5feb\uff01<\/p>\n<p>\u597d\u4e86\uff0c\u672c\u6587\u5230\u6b64\u7ed3\u675f\uff0c\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u300a\u63a2\u7d22\u89d2\u5ea6\u5f62\u5f0f\uff1a\u4fe1\u53f7\u7684\u65b0\u66ff\u4ee3\u65b9\u6848\u300b\uff0c\u5e0c\u671b\u672c\u6587\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff01\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u7ed9\u5927\u5bb6\u5206\u4eab\u66f4\u591a\u6587\u7ae0\u77e5\u8bc6\uff01<\/p>\n<p>      \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1adev.to \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb\u5220\u9664    <\/p>\n<dl>\n<dt><\/dt>\n<dd>\n   \u5982\u4f55\u4f7f\u7528 Laravel \u6846\u67b6\u8f7b\u677e\u5c01\u88c5\u5fae\u4fe1\u652f\u4ed8\u548c\u652f\u4ed8\u5b9d\u652f\u4ed8\uff1f\n <\/dd>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22\u89d2\u5ea6\u5f62\u5f0f\uff1a\u4fe1\u53f7\u7684\u65b0\u66ff\u4ee3\u65b9\u6848 \u6536\u85cf \u5b66\u4e60\u77e5\u8bc6\u8981\u5584\u4e8e\u601d\u8003\uff0c\u601d\u8003\uff0c\u518d\u601d\u8003\uff01\u4eca\u5929\u7c73\u4e91\u5c0f\u7f16\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765\u300a\u63a2\u7d22\u89d2\u5ea6\u5f62\u5f0f\uff1a\u4fe1\u53f7\u7684\u65b0\u66ff\u4ee3\u65b9\u6848\u300b\uff0c\u4ee5\u4e0b\u5185\u5bb9\u4e3b\u8981\u5305\u542b\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u6b63\u5728\u5b66\u4e60\u6216\u51c6\u5907\u5b66\u4e60\u6587\u7ae0\uff0c\u5c31\u90fd\u4e0d\u8981\u9519\u8fc7\u672c\u6587\u5566~\u8ba9\u6211\u4eec\u4e00\u8d77\u6765\u770b\u770b\u5427\uff0c\u80fd\u5e2e\u52a9\u5230\u4f60\u5c31\u66f4\u597d\u4e86\uff01 \u63a2\u7d22\u89d2\u5ea6\u5f62\u5f0f\uff1a\u4fe1\u53f7\u7684\u65b0\u66ff\u4ee3\u65b9\u6848 \u5728 angular \u7684\u4e16\u754c\u4e2d\uff0c\u65e0\u8bba\u60a8\u662f\u5728\u5236\u4f5c\u7b80\u5355\u7684\u767b\u5f55\u9875\u9762\u8fd8\u662f\u66f4\u590d\u6742\u7684\u7528\u6237\u914d\u7f6e\u6587\u4ef6\u754c\u9762\uff0c\u8868\u5355\u5bf9\u4e8e\u7528\u6237\u4ea4\u4e92\u90fd\u662f\u81f3\u5173\u91cd\u8981\u7684\u3002 angular \u4f20\u7edf\u4e0a\u63d0\u4f9b\u4e24\u79cd\u4e3b\u8981\u65b9\u6cd5\uff1a\u6a21\u677f\u9a71\u52a8\u8868\u5355\u548c\u53cd\u5e94\u5f0f\u8868\u5355\u3002\u5728\u6211\u4e4b\u524d\u7684 angular \u53cd\u5e94\u5f0f\u8868\u5355\u7cfb\u5217\u4e2d\uff0c\u6211\u63a2\u7d22\u4e86\u5982\u4f55\u5229\u7528\u53cd\u5e94\u5f0f\u8868\u5355\u7684\u5f3a\u5927\u529f\u80fd\u6765\u7ba1\u7406\u590d\u6742\u903b\u8f91\u3001\u521b\u5efa\u52a8\u6001\u8868\u5355\u4ee5\u53ca\u6784\u5efa\u81ea\u5b9a\u4e49\u8868\u5355\u63a7\u4ef6\u3002 \u7528\u4e8e\u7ba1\u7406\u53cd\u5e94\u6027\u7684\u65b0\u5de5\u5177 &#8211; \u4fe1\u53f7 &#8211; \u5df2\u5728 angular \u7248\u672c 16 \u4e2d\u5f15\u5165\uff0c\u6b64\u540e\u4e00\u76f4\u662f angular \u7ef4\u62a4\u4eba\u5458\u5173\u6ce8\u7684\u7126\u70b9\uff0c\u5e76\u5728\u7248\u672c 17 \u4e2d\u53d8\u5f97\u7a33\u5b9a\u3002\u4fe1\u53f7\u5141\u8bb8\u60a8\u5904\u7406\u72b6\u6001\u66f4\u6539\u58f0\u660e\u6027\u5730\uff0c\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4ee4\u4eba\u5174\u594b\u7684\u66ff\u4ee3\u65b9\u6848\uff0c\u5c06\u6a21\u677f\u9a71\u52a8\u8868\u5355\u7684\u7b80\u5355\u6027\u4e0e\u53cd\u5e94\u8868\u5355\u7684\u5f3a\u5927\u53cd\u5e94\u6027\u7ed3\u5408\u8d77\u6765\u3002\u672c\u6587\u5c06\u7814\u7a76\u4fe1\u53f7\u5982\u4f55\u4e3a angular \u4e2d\u7684\u7b80\u5355\u548c\u590d\u6742\u5f62\u5f0f\u6dfb\u52a0\u53cd\u5e94\u6027\u3002 \u56de\u987e\uff1a\u89d2\u5ea6\u5f62\u5f0f\u65b9\u6cd5 \u5728\u6df1\u5165\u63a2\u8ba8\u4f7f\u7528\u4fe1\u53f7\u589e\u5f3a\u6a21\u677f\u9a71\u52a8\u8868\u5355\u7684\u4e3b\u9898\u4e4b\u524d\uff0c\u8ba9\u6211\u4eec\u5feb\u901f\u56de\u987e\u4e00\u4e0b angular \u7684\u4f20\u7edf\u8868\u5355\u65b9\u6cd5\uff1a \u6a21\u677f\u9a71\u52a8\u8868\u5355\uff1a\u4f7f\u7528 ngmodel \u7b49\u6307\u4ee4\u76f4\u63a5\u5728 html \u6a21\u677f\u4e2d\u5b9a\u4e49\uff0c\u8fd9\u4e9b\u8868\u5355\u6613\u4e8e\u8bbe\u7f6e\uff0c\u975e\u5e38\u9002\u5408\u7b80\u5355\u8868\u5355\u3002\u4f46\u662f\uff0c\u5b83\u4eec\u53ef\u80fd\u65e0\u6cd5\u63d0\u4f9b\u66f4\u590d\u6742\u573a\u666f\u6240\u9700\u7684\u7ec6\u7c92\u5ea6\u63a7\u5236\u3002 \u8fd9\u662f\u6a21\u677f\u9a71\u52a8\u8868\u5355\u7684\u6700\u5c0f\u793a\u4f8b\uff1a &lt;form (ngsubmit)=&#8221;onsubmit()&#8221;&gt; &lt;label for=&#8221;name&#8221;&gt;name:&lt;\/label&gt; &lt;input id=&#8221;name&#8221; [(ngmodel)]=&#8221;name&#8221; name=&#8221;name&#8221;&gt; &lt;button type=&#8221;submit&#8221;&gt;submit&lt;\/button&gt; &lt;\/form&gt; &#8220;`typescript import { component } from &#8216;@angular\/core&#8217;; @component({ [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-52668","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52668","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=52668"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52668\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}