{"id":26015,"date":"2024-02-21T10:40:11","date_gmt":"2024-02-21T09:40:11","guid":{"rendered":"https:\/\/www.codemotion.com\/magazine\/?p=26015"},"modified":"2024-02-21T11:05:35","modified_gmt":"2024-02-21T10:05:35","slug":"angular-model-inputs-two-way-binding-inputs-with-signals","status":"publish","type":"post","link":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/","title":{"rendered":"Angular Model Inputs: two-way binding inputs with\u00a0Signals"},"content":{"rendered":"\n<p><br><strong>Angular v17.2.0<\/strong> introduces a new api to allow two-way binding with Signal Inputs: <strong>Model Inputs<\/strong>.<\/p>\n\n\n\n<p>Before proceeding, I kindly suggest you to read my previous article \u201c<strong><a href=\"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-signal-inputs\/\" target=\"_blank\" aria-label=\"Angular Signal Inputs: road to Signal Components (opens in a new tab)\" rel=\"noreferrer noopener\" class=\"ek-link\">Angular Signal Inputs: road to Signal Components<\/a><\/strong>\u201d, in which I discussed about Signal Inputs and how they work.&nbsp;<\/p>\n\n\n\n<p>This article is strictly connected to the previous, and is meant to fulfill the open point about the <strong>two-way binding<\/strong> with <strong>Signal Inputs<\/strong>.<\/p>\n\n\n\n<p>Now that <strong>Model Inputs<\/strong> are available it\u2019s time to dive deeper into them.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"has-text-align-center\">\u26a0\ufe0f <strong>ALERT:<\/strong> new <strong>Model Inputs <\/strong>are still in developer preview \u26a0\ufe0f<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-how-to-create-a-model-nbsp-input\">How to create a Model&nbsp;Input<\/h3>\n\n\n\n<p>Just like Signal Inputs, <strong>Model Inputs<\/strong> are meant to replace classic inputs created with the <strong>@Input( )<\/strong> decorator, exposing the input value as a Signal.<\/p>\n\n\n\n<p>To create a <strong>Model Input<\/strong> you just need to use the <strong>model( )<\/strong> function provided by <strong>@angular\/core<\/strong> package:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"TypeScript\" data-shcb-language-slug=\"typescript\"><span><code class=\"hljs language-typescript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span><span class=\"hljs-keyword\">import<\/span> { Component, model, ModelSignal } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'@angular\/core'<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-meta\">@Component<\/span>({ ... })\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">class<\/span> MyComponent {\n<\/span><\/span><mark class='shcb-loc'><span>  myProp: ModelSignal&lt;<span class=\"hljs-built_in\">string<\/span> | <span class=\"hljs-literal\">undefined<\/span>&gt; = model&lt;<span class=\"hljs-built_in\">string<\/span>&gt;();\n<\/span><\/mark><span class='shcb-loc'><span>}\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">TypeScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">typescript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Your input will be typed as <strong>ModelSignal<\/strong>, a special type of Signal that Angular internally updates whenever a new value is bound.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-the-update-nbsp-function\">The update( )&nbsp;function<\/h4>\n\n\n\n<p>Two-way binding allows both parent and child components to update the value of a bonded input and to share then the same identical value.<\/p>\n\n\n\n<p>To enable the update from the child component, <strong>ModelSignal<\/strong> api exposes a dedicated <strong>update( )<\/strong> function to update an input based on the current value:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"TypeScript\" data-shcb-language-slug=\"typescript\"><span><code class=\"hljs language-typescript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span>updateProp(): <span class=\"hljs-built_in\">void<\/span> {\n<\/span><\/span><mark class='shcb-loc'><span>  <span class=\"hljs-keyword\">this<\/span>.myProp.update(<span class=\"hljs-function\">(<span class=\"hljs-params\"><span class=\"hljs-params\">current<\/span><\/span>) =&gt;<\/span> current + <span class=\"hljs-string\">' - Updated!!!'<\/span>);\n<\/span><\/mark><span class='shcb-loc'><span>}\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">TypeScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">typescript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"h-the-two-way-nbsp-binding\"><strong>The two-way&nbsp;binding<\/strong><\/h4>\n\n\n\n<p>Using Angular\u2019s <strong>two-way binding<\/strong> syntax when binding a value from the parent component to the child component, the <strong>ModelSignal <\/strong>update from the child component will therefore go back up to the parent component:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">my-component<\/span><\/span>\n<\/span><\/span><mark class='shcb-loc'><span><span class=\"hljs-tag\">  &#91;(<span class=\"hljs-attr\">myProp<\/span>)]=<span class=\"hljs-string\">\"parentProp\"<\/span><\/span>\n<\/span><\/mark><mark class='shcb-loc'><span><span class=\"hljs-tag\">  (<span class=\"hljs-attr\">myPropChange<\/span>)=<span class=\"hljs-string\">\"onPropChangeMethod($event)\"<\/span><\/span>\n<\/span><\/mark><span class='shcb-loc'><span><span class=\"hljs-tag\">&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">my-component<\/span>&gt;<\/span>\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Both parent and child component will have the property value synced.<br>The parent component will also get an output notification named as the input name with <code><strong>Change<\/strong><\/code> appended, carrying the new value as event object.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-model-inputs-with-default-and-required-nbsp-values\">Model Inputs with default and required&nbsp;values<\/h3>\n\n\n\n<p>As you probably noticed in the previous examples, by creating a <strong>Model Input<\/strong> you can provide to the <strong>model( )<\/strong> function a type argument to define the type of the <strong>ModelSignal<\/strong> value:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"TypeScript\" data-shcb-language-slug=\"typescript\"><span><code class=\"hljs language-typescript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span><span class=\"hljs-keyword\">import<\/span> { Component, model, ModelSignal } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'@angular\/core'<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-meta\">@Component<\/span>({ ... })\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">class<\/span> MyComponent {\n<\/span><\/span><mark class='shcb-loc'><span>  myProp: ModelSignal&lt;<span class=\"hljs-built_in\">string<\/span> | <span class=\"hljs-literal\">undefined<\/span>&gt; = model&lt;<span class=\"hljs-built_in\">string<\/span>&gt;();\n<\/span><\/mark><span class='shcb-loc'><span>}\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">TypeScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">typescript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Due to the <strong>optional<\/strong> nature of the input value, <strong>ModelSignal<\/strong> values are typed as possibly <strong>undefined.<\/strong><\/p>\n\n\n\n<p>To get rid of those, you can provide a <strong>default value<\/strong> to the <strong>model( )<\/strong> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"TypeScript\" data-shcb-language-slug=\"typescript\"><span><code class=\"hljs language-typescript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span>myProp: ModelSignal&lt;<span class=\"hljs-built_in\">string<\/span>&gt; = model(<span class=\"hljs-string\">'default'<\/span>);\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">TypeScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">typescript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Alternatively, you can define your <strong>Model Inputs<\/strong> as required thought a dedicated <strong>model.required( )<\/strong> function:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"TypeScript\" data-shcb-language-slug=\"typescript\"><span><code class=\"hljs language-typescript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span>myRequiredProp: ModelSignal&lt;<span class=\"hljs-built_in\">string<\/span>&gt; = model.required&lt;<span class=\"hljs-built_in\">string<\/span>&gt;();\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">TypeScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">typescript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-input-options-alias-and-transform-function\">Input options: alias and transform function<\/h3>\n\n\n\n<p>As classic Angular inputs, <strong>Model Inputs <\/strong>support also the <strong>alias<\/strong> option:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"TypeScript\" data-shcb-language-slug=\"typescript\"><span><code class=\"hljs language-typescript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span>myProp = model(<span class=\"hljs-string\">'default-value'<\/span>, { alias: <span class=\"hljs-string\">'myPropAlias'<\/span> });\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">TypeScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">typescript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Allowing us to decouple the child component input variable name and the DOM property name used by parent components to bound the input value:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">my-component<\/span> &#91;(<span class=\"hljs-attr\">myPropAlias<\/span>)]=<span class=\"hljs-string\">\"parentProp\"<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">my-component<\/span>&gt;<\/span>\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h4 class=\"wp-block-heading\" id=\"h-where-is-the-transform-function\">Where is the transform( ) function?<\/h4>\n\n\n\n<p>Regarding the <strong>transform( )<\/strong> function, the last classic inputs option we are familiar with, the <strong>model( )<\/strong> function does not support it.<\/p>\n\n\n\n<p>This make sense to me, just think about the conflicts between the two-way nature of <strong>Model Inputs<\/strong>, and the role of the <strong>transform( )<\/strong> function to transform the input value only inside a component.<\/p>\n\n\n\n<p>Luckily, you can overcome this absence using the <strong>computed( )<\/strong> function, which allows you to define derived values starting from a Signal:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"TypeScript\" data-shcb-language-slug=\"typescript\"><span><code class=\"hljs language-typescript shcb-code-table shcb-line-numbers\"><span class='shcb-loc'><span><span class=\"hljs-keyword\">import<\/span> { Component, computed, model, ModelSignal, Signal } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'@angular\/core'<\/span>;\n<\/span><\/span><span class='shcb-loc'><span>\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-meta\">@Component<\/span>({ ... })\n<\/span><\/span><span class='shcb-loc'><span><span class=\"hljs-keyword\">export<\/span> <span class=\"hljs-keyword\">class<\/span> MyComponent {\n<\/span><\/span><mark class='shcb-loc'><span>  myProp: ModelSignal&lt;<span class=\"hljs-built_in\">string<\/span>&gt; = model(<span class=\"hljs-string\">'default'<\/span>);\n<\/span><\/mark><span class='shcb-loc'><span>\n<\/span><\/span><mark class='shcb-loc'><span>  myComposedProp: Signal&lt;<span class=\"hljs-built_in\">number<\/span>&gt; = computed(\n<\/span><\/mark><mark class='shcb-loc'><span>    <span class=\"hljs-function\"><span class=\"hljs-params\">()<\/span> =&gt;<\/span> <span class=\"hljs-keyword\">this<\/span>.modelOptional()?.length || <span class=\"hljs-number\">0<\/span>\n<\/span><\/mark><mark class='shcb-loc'><span>  );\n<\/span><\/mark><span class='shcb-loc'><span>}\n<\/span><\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">TypeScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">typescript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>In this way the value defined using the <strong>computed( )<\/strong> function is confined inside child component.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-dots\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-thanks-for-reading-so-far-nbsp\">Thanks for reading so far&nbsp;\ud83d\ude4f<\/h3>\n\n\n\n<p>That\u2019s all about <strong>Model Inputs<\/strong>.<\/p>\n\n\n\n<p>If you did not, I recommend you to read my previous article \u201c<strong><a aria-label=\"Angular Signal Inputs: road to Signal Components (opens in a new tab)\" href=\"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-signal-inputs\/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"ek-link\">Angular Signal Inputs: road to Signal Components<\/a><\/strong>\u201d. <br>There you will found a more exhaust explanation about the advantages of using <strong>Signal Inputs<\/strong> and <strong>Model Inputs<\/strong>.<\/p>\n\n\n\n<p>As always, I\u2019d like to have your feedback. \ud83d\udc4b<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Angular v17.2.0 introduces a new api to allow two-way binding with Signal Inputs: Model Inputs. Before proceeding, I kindly suggest you to read my previous article \u201cAngular Signal Inputs: road to Signal Components\u201d, in which I discussed about Signal Inputs and how they work.&nbsp; This article is strictly connected to the previous, and is meant&#8230; <a class=\"more-link\" href=\"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/\">Read more<\/a><\/p>\n","protected":false},"author":200,"featured_media":26069,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_editorskit_title_hidden":false,"_editorskit_reading_time":0,"_editorskit_is_block_options_detached":false,"_editorskit_block_options_position":"{}","_uag_custom_page_level_css":"","_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[6],"tags":[4141],"collections":[],"class_list":{"0":"post-26015","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-frontend","8":"tag-angular","9":"entry"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Angular Model Inputs: two-way binding inputs with\u00a0Signals - Codemotion Magazine<\/title>\n<meta name=\"description\" content=\"The journey towards the integration of Signals has moved forward with the release of Angular v17.2.0, introducing the new Model Inputs api.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Angular Model Inputs: two-way binding inputs with\u00a0Signals\" \/>\n<meta property=\"og:description\" content=\"The journey towards the integration of Signals has moved forward with the release of Angular v17.2.0, introducing the new Model Inputs api.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/\" \/>\n<meta property=\"og:site_name\" content=\"Codemotion Magazine\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Codemotion.Italy\/\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-21T09:40:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-21T10:05:35+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way.png\" \/>\n\t<meta property=\"og:image:width\" content=\"992\" \/>\n\t<meta property=\"og:image:height\" content=\"558\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Davide Passafaro\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CodemotionIT\" \/>\n<meta name=\"twitter:site\" content=\"@CodemotionIT\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Davide Passafaro\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/angular-model-inputs-two-way-binding-inputs-with-signals\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/angular-model-inputs-two-way-binding-inputs-with-signals\\\/\"},\"author\":{\"name\":\"Davide Passafaro\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#\\\/schema\\\/person\\\/79170e2a1bfc41ddeaa10827ce803828\"},\"headline\":\"Angular Model Inputs: two-way binding inputs with\u00a0Signals\",\"datePublished\":\"2024-02-21T09:40:11+00:00\",\"dateModified\":\"2024-02-21T10:05:35+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/angular-model-inputs-two-way-binding-inputs-with-signals\\\/\"},\"wordCount\":572,\"publisher\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/angular-model-inputs-two-way-binding-inputs-with-signals\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2024\\\/02\\\/angular-two-way.png\",\"keywords\":[\"Angular\"],\"articleSection\":[\"Frontend\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/angular-model-inputs-two-way-binding-inputs-with-signals\\\/\",\"url\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/angular-model-inputs-two-way-binding-inputs-with-signals\\\/\",\"name\":\"Angular Model Inputs: two-way binding inputs with\u00a0Signals - Codemotion Magazine\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/angular-model-inputs-two-way-binding-inputs-with-signals\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/angular-model-inputs-two-way-binding-inputs-with-signals\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2024\\\/02\\\/angular-two-way.png\",\"datePublished\":\"2024-02-21T09:40:11+00:00\",\"dateModified\":\"2024-02-21T10:05:35+00:00\",\"description\":\"The journey towards the integration of Signals has moved forward with the release of Angular v17.2.0, introducing the new Model Inputs api.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/angular-model-inputs-two-way-binding-inputs-with-signals\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/angular-model-inputs-two-way-binding-inputs-with-signals\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/angular-model-inputs-two-way-binding-inputs-with-signals\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2024\\\/02\\\/angular-two-way.png\",\"contentUrl\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2024\\\/02\\\/angular-two-way.png\",\"width\":992,\"height\":558,\"caption\":\"angular input two way\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/angular-model-inputs-two-way-binding-inputs-with-signals\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Frontend\",\"item\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/frontend\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Angular Model Inputs: two-way binding inputs with\u00a0Signals\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#website\",\"url\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/\",\"name\":\"Codemotion Magazine\",\"description\":\"We code the future. Together\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#organization\",\"name\":\"Codemotion\",\"url\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2019\\\/11\\\/codemotionlogo.png\",\"contentUrl\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2019\\\/11\\\/codemotionlogo.png\",\"width\":225,\"height\":225,\"caption\":\"Codemotion\"},\"image\":{\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/Codemotion.Italy\\\/\",\"https:\\\/\\\/x.com\\\/CodemotionIT\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/#\\\/schema\\\/person\\\/79170e2a1bfc41ddeaa10827ce803828\",\"name\":\"Davide Passafaro\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/Immagine-profilo-GDE-430kb-100x100.png\",\"url\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/Immagine-profilo-GDE-430kb-100x100.png\",\"contentUrl\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/wp-content\\\/uploads\\\/2026\\\/05\\\/Immagine-profilo-GDE-430kb-100x100.png\",\"caption\":\"Davide Passafaro\"},\"description\":\"My name is Davide Passafaro and I am Senior Frontend Engineer at Awork. I lead two developer communities in Rome, GDG Roma Citt\u00e0 and Angular Rome, and actively contribute to the tech community as a writer and speaker. When i shut down my computer I like to play board games and archery, not both together till now. I also like escape rooms and memes.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/davide-passafaro\\\/\"],\"url\":\"https:\\\/\\\/www.codemotion.com\\\/magazine\\\/author\\\/davidepassafaro\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Angular Model Inputs: two-way binding inputs with\u00a0Signals - Codemotion Magazine","description":"The journey towards the integration of Signals has moved forward with the release of Angular v17.2.0, introducing the new Model Inputs api.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/","og_locale":"en_US","og_type":"article","og_title":"Angular Model Inputs: two-way binding inputs with\u00a0Signals","og_description":"The journey towards the integration of Signals has moved forward with the release of Angular v17.2.0, introducing the new Model Inputs api.","og_url":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/","og_site_name":"Codemotion Magazine","article_publisher":"https:\/\/www.facebook.com\/Codemotion.Italy\/","article_published_time":"2024-02-21T09:40:11+00:00","article_modified_time":"2024-02-21T10:05:35+00:00","og_image":[{"width":992,"height":558,"url":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way.png","type":"image\/png"}],"author":"Davide Passafaro","twitter_card":"summary_large_image","twitter_creator":"@CodemotionIT","twitter_site":"@CodemotionIT","twitter_misc":{"Written by":"Davide Passafaro","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/#article","isPartOf":{"@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/"},"author":{"name":"Davide Passafaro","@id":"https:\/\/www.codemotion.com\/magazine\/#\/schema\/person\/79170e2a1bfc41ddeaa10827ce803828"},"headline":"Angular Model Inputs: two-way binding inputs with\u00a0Signals","datePublished":"2024-02-21T09:40:11+00:00","dateModified":"2024-02-21T10:05:35+00:00","mainEntityOfPage":{"@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/"},"wordCount":572,"publisher":{"@id":"https:\/\/www.codemotion.com\/magazine\/#organization"},"image":{"@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way.png","keywords":["Angular"],"articleSection":["Frontend"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/","url":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/","name":"Angular Model Inputs: two-way binding inputs with\u00a0Signals - Codemotion Magazine","isPartOf":{"@id":"https:\/\/www.codemotion.com\/magazine\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/#primaryimage"},"image":{"@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/#primaryimage"},"thumbnailUrl":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way.png","datePublished":"2024-02-21T09:40:11+00:00","dateModified":"2024-02-21T10:05:35+00:00","description":"The journey towards the integration of Signals has moved forward with the release of Angular v17.2.0, introducing the new Model Inputs api.","breadcrumb":{"@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/#primaryimage","url":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way.png","contentUrl":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way.png","width":992,"height":558,"caption":"angular input two way"},{"@type":"BreadcrumbList","@id":"https:\/\/www.codemotion.com\/magazine\/frontend\/angular-model-inputs-two-way-binding-inputs-with-signals\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.codemotion.com\/magazine\/"},{"@type":"ListItem","position":2,"name":"Frontend","item":"https:\/\/www.codemotion.com\/magazine\/frontend\/"},{"@type":"ListItem","position":3,"name":"Angular Model Inputs: two-way binding inputs with\u00a0Signals"}]},{"@type":"WebSite","@id":"https:\/\/www.codemotion.com\/magazine\/#website","url":"https:\/\/www.codemotion.com\/magazine\/","name":"Codemotion Magazine","description":"We code the future. Together","publisher":{"@id":"https:\/\/www.codemotion.com\/magazine\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.codemotion.com\/magazine\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.codemotion.com\/magazine\/#organization","name":"Codemotion","url":"https:\/\/www.codemotion.com\/magazine\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codemotion.com\/magazine\/#\/schema\/logo\/image\/","url":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/11\/codemotionlogo.png","contentUrl":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2019\/11\/codemotionlogo.png","width":225,"height":225,"caption":"Codemotion"},"image":{"@id":"https:\/\/www.codemotion.com\/magazine\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Codemotion.Italy\/","https:\/\/x.com\/CodemotionIT"]},{"@type":"Person","@id":"https:\/\/www.codemotion.com\/magazine\/#\/schema\/person\/79170e2a1bfc41ddeaa10827ce803828","name":"Davide Passafaro","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2026\/05\/Immagine-profilo-GDE-430kb-100x100.png","url":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2026\/05\/Immagine-profilo-GDE-430kb-100x100.png","contentUrl":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2026\/05\/Immagine-profilo-GDE-430kb-100x100.png","caption":"Davide Passafaro"},"description":"My name is Davide Passafaro and I am Senior Frontend Engineer at Awork. I lead two developer communities in Rome, GDG Roma Citt\u00e0 and Angular Rome, and actively contribute to the tech community as a writer and speaker. When i shut down my computer I like to play board games and archery, not both together till now. I also like escape rooms and memes.","sameAs":["https:\/\/www.linkedin.com\/in\/davide-passafaro\/"],"url":"https:\/\/www.codemotion.com\/magazine\/author\/davidepassafaro\/"}]}},"featured_image_src":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way-600x400.png","featured_image_src_square":"https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way-600x558.png","author_info":{"display_name":"Davide Passafaro","author_link":"https:\/\/www.codemotion.com\/magazine\/author\/davidepassafaro\/"},"uagb_featured_image_src":{"full":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way.png",992,558,false],"thumbnail":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way-150x150.png",150,150,true],"medium":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way-300x169.png",300,169,true],"medium_large":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way-768x432.png",768,432,true],"large":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way.png",992,558,false],"1536x1536":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way.png",992,558,false],"2048x2048":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way.png",992,558,false],"small-home-featured":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way-100x100.png",100,100,true],"sidebar-featured":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way-180x128.png",180,128,true],"genesis-singular-images":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way-896x504.png",896,504,true],"archive-featured":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way-400x225.png",400,225,true],"gb-block-post-grid-landscape":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way-600x400.png",600,400,true],"gb-block-post-grid-square":["https:\/\/www.codemotion.com\/magazine\/wp-content\/uploads\/2024\/02\/angular-two-way-600x558.png",600,558,true]},"uagb_author_info":{"display_name":"Davide Passafaro","author_link":"https:\/\/www.codemotion.com\/magazine\/author\/davidepassafaro\/"},"uagb_comment_info":0,"uagb_excerpt":"Angular v17.2.0 introduces a new api to allow two-way binding with Signal Inputs: Model Inputs. Before proceeding, I kindly suggest you to read my previous article \u201cAngular Signal Inputs: road to Signal Components\u201d, in which I discussed about Signal Inputs and how they work.&nbsp; This article is strictly connected to the previous, and is meant&#8230;&hellip;","lang":"en","_links":{"self":[{"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/posts\/26015","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/users\/200"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/comments?post=26015"}],"version-history":[{"count":2,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/posts\/26015\/revisions"}],"predecessor-version":[{"id":26074,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/posts\/26015\/revisions\/26074"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/media\/26069"}],"wp:attachment":[{"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/media?parent=26015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/categories?post=26015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/tags?post=26015"},{"taxonomy":"collections","embeddable":true,"href":"https:\/\/www.codemotion.com\/magazine\/wp-json\/wp\/v2\/collections?post=26015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}