<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Technbuzz.com</title>
	<atom:link href="https://www.technbuzz.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.technbuzz.com/</link>
	<description>Frontend in Development</description>
	<lastBuildDate>Thu, 28 May 2026 17:38:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://www.technbuzz.com/wp-content/uploads/2020/07/cropped-3-32x32.png</url>
	<title>Technbuzz.com</title>
	<link>https://www.technbuzz.com/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">106603229</site>	<item>
		<title>Combine Two PDF Pages into One with variable width</title>
		<link>https://www.technbuzz.com/2026/05/28/combine-two-pdf-pages-into-one-with-variable-width/</link>
					<comments>https://www.technbuzz.com/2026/05/28/combine-two-pdf-pages-into-one-with-variable-width/#respond</comments>
		
		<dc:creator><![CDATA[Samiullah Khan]]></dc:creator>
		<pubDate>Thu, 28 May 2026 09:25:22 +0000</pubDate>
				<category><![CDATA[Java Script]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[aspect-ratio]]></category>
		<category><![CDATA[center-align]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[pdf-lib]]></category>
		<guid isPermaLink="false">https://www.technbuzz.com/?p=3652</guid>

					<description><![CDATA[<p>This post is the extension to the previous tutorial. This tutorial add the width and height controls. User can change the width of embedded page and can visually see it&#8217;s impact on final PDF in realtime. Implementation We will continue with updating the HTML markup We have added the two inputs. One for width and [&#8230;]</p>
<p>The post <a href="https://www.technbuzz.com/2026/05/28/combine-two-pdf-pages-into-one-with-variable-width/">Combine Two PDF Pages into One with variable width</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This post is the extension to the <a href="https://www.technbuzz.com/2026/05/23/pdf-two-page-to-single-page-in-javascript-pdf-lib/" type="post" id="3631">previous tutorial</a>. This tutorial add the width  and height controls. User can change the width of embedded page and can visually see it&#8217;s impact on final PDF in realtime.</p>



<h2 class="wp-block-heading">Implementation</h2>



<p>We will continue with updating the HTML markup</p>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-html"><code>&lt;main>
  &lt;input id="fileInput" type="file" accept=".pdf" />
  &lt;label>Width &lt;input class="widthInput" step="25" type="number" min="200" max="600" />&lt;/label>
  &lt;label>Height &lt;input readonly class="heightInput" type="number" min="0" max="500" />&lt;/label>
&lt;/main>
</code></pre></div>



<p>We have added the two inputs. One for <strong>width</strong> and one for <strong>height</strong>. The height one is <em>readonly</em> as we want to maintain the aspect ratio when width is changed, more on that later.</p>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-css"><code>.widthInput, .heightInput {
  width: 5rem;
}</code></pre></div>



<p>We just increased the default width of those input elements.</p>



<p>// output goes here</p>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-js"><code>const widthEl = document.querySelector('input[type="number"].widthInput') as HTMLInputElement
const heightEl = document.querySelector('input[type="number"].heightInput') as HTMLInputElement

widthEl?.addEventListener('change',  event => {
  const value = (event.target as HTMLInputElement).valueAsNumber
  createDocument(firstPage, secondPage, value)
}</code></pre></div>



<p>We have some references of dom elements with some type assertions to HTMLInputElements to silence some typescript errors.</p>



<p>Next we listen to change in the <strong>width input</strong> and react to the document creation accordingly. Our <code>createDocument</code> function accepts third argument, guess what <strong>the width</strong></p>



<h3 class="wp-block-heading">What&#8217;s new in create document?</h3>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-js line-numbers"><code>async function createDocument(pageAToEmbed: PDFPage, pageBToEmbed: PDFPage, width = PageSizes.A4[0] ) {
  // .....
  let [, height] = PageSizes.A4;
  const calcHeight = aspectCorrectDimension(width);
</code></pre></div>



<p>The third argument is <code>width= PageSize.A4[0]</code>, we are setting the default value to <strong>A4 page width</strong> for the first run of the function. As this function also runs when the width is changed.</p>



<p>In <strong>Line 3</strong> we skip the width and only de-structure the height</p>



<p>Let&#8217;s explain the what&#8217;s happening on <strong>Line 4</strong></p>



<h3 class="wp-block-heading">aspectCorrectDimension</h3>



<p>We need to calculate the <strong>aspect ratio</strong> of the A4 page. The dimension of A4 page is 545 x 841 in pixels. We embedded takes half of the page so our dimensions becomes 545 x 420.5. The aspect ratio becomes</p>



<div class="wp-block-math"><math display="block"><semantics><mrow><mn>545</mn><mi>/</mi><mn>420.5</mn><mo>=</mo><mn>1.296</mn></mrow><annotation encoding="application/x-tex">545 / 420.5 =1.296 </annotation></semantics></math></div>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-js"><code>/**
 * Decimal Ratio
 * 545 ÷ 420.5 ≈ 1.296
 */
function aspectCorrectDimension(width: number) {
  const aR = 1.296;
  return width / aR
}</code></pre></div>



<p>Our function calculates the appropriate height to maintain the aspect ratio.</p>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-js"><code>  page.drawPage(embeddedPageA, { x: 10, y: height/2, width: width, height: calcHeight })

  widthEl.value = String(width); 
  heightEl.value = String(calcHeight);

  page.drawPage(embeddedPageB, { x: 10, y: 0, width, height: calcHeight})
  .../
}
</code></pre></div>



<p>We have update the height config for the <em>drawPage method</em> with newly <strong>calculatedHeight</strong>. We also need to update the input controls as well and that&#8217;s it.</p>



<h3 class="wp-block-heading">Output</h3>



<figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe class="youtube-player" width="580" height="327" src="https://www.youtube.com/embed/XKqltJywSy8?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=en-US&#038;autohide=2&#038;wmode=transparent" allowfullscreen="true" style="border:0;" sandbox="allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox"></iframe>
</div></figure>



<h3 class="wp-block-heading">Horizontally centering</h3>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-js"><code>const remainder = (PageSizes.A4[0] - width) / 2
const centeredX = remainder

page.drawPage(embeddedPageA, { x: centeredX, y: height/2, width: width, height: calcHeight })

//...

page.drawPage(embeddedPageB, { x: centeredX, y: 0, width, height: calcHeight})</code></pre></div>



<p>We have updated the <code>x: centeredX</code> which is calculated by some subtraction and division. This way, our faces remains always in the center.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>We have introduced some input elements. Change in width recalculates the dimension of card face while maintaining the aspect ration and embeds it.</p>
<p>The post <a href="https://www.technbuzz.com/2026/05/28/combine-two-pdf-pages-into-one-with-variable-width/">Combine Two PDF Pages into One with variable width</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.technbuzz.com/2026/05/28/combine-two-pdf-pages-into-one-with-variable-width/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3652</post-id>	</item>
		<item>
		<title>Combine Two PDF Pages into One with pdf-lib</title>
		<link>https://www.technbuzz.com/2026/05/23/pdf-two-page-to-single-page-in-javascript-pdf-lib/</link>
					<comments>https://www.technbuzz.com/2026/05/23/pdf-two-page-to-single-page-in-javascript-pdf-lib/#respond</comments>
		
		<dc:creator><![CDATA[Samiullah Khan]]></dc:creator>
		<pubDate>Sat, 23 May 2026 09:26:33 +0000</pubDate>
				<category><![CDATA[Java Script]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[arraybuffer]]></category>
		<category><![CDATA[dataurl]]></category>
		<category><![CDATA[iframe]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[pdf-lib]]></category>
		<guid isPermaLink="false">https://www.technbuzz.com/?p=3631</guid>

					<description><![CDATA[<p>I have this recurring need where we I have PDF of national Identity Cards. It has front side and back side. Both in separate pages. Most often than not I need to move it to single page PDF. This was it&#8217;s easy to print (thought print tool does this is without much trouble) and some [&#8230;]</p>
<p>The post <a href="https://www.technbuzz.com/2026/05/23/pdf-two-page-to-single-page-in-javascript-pdf-lib/">Combine Two PDF Pages into One with pdf-lib</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>I have this recurring need where we I have PDF of national Identity Cards. It has front side and back side. Both in separate pages. </p>



<p>Most often than not I need to move it to single page PDF. This was it&#8217;s easy to print (thought print tool does this is without much trouble) and some government entities accept images, so it&#8217;s easy to export one file Pdf to image rather than two page Pdf.</p>



<p>We will achieve exactly that using awesome <a href="https://pdf-lib.js.org/">pdf-lib</a>. It can create, modify PDF. We can draw elements like text, graphics to it. It can also merge and split PDF files.</p>



<h2 class="wp-block-heading">Planning</h2>



<p>We need three major steps</p>



<ol class="wp-block-list">
<li>Accept existing PDF file</li>



<li>Manipulate it using pdf-lib</li>



<li>Display it using iframe</li>
</ol>



<p>Our rough layout will look like this</p>



<figure class="wp-block-image size-full"><a href="https://www.technbuzz.com/wp-content/uploads/2026/05/manipulate-pdf-with-js-technbuzz.com_.png"><img fetchpriority="high" decoding="async" width="1009" height="765" src="https://www.technbuzz.com/wp-content/uploads/2026/05/manipulate-pdf-with-js-technbuzz.com_.png" alt="A wireframe of input file type and file viewer section" class="wp-image-3632" srcset="https://www.technbuzz.com/wp-content/uploads/2026/05/manipulate-pdf-with-js-technbuzz.com_.png 1009w, https://www.technbuzz.com/wp-content/uploads/2026/05/manipulate-pdf-with-js-technbuzz.com_-300x227.png 300w, https://www.technbuzz.com/wp-content/uploads/2026/05/manipulate-pdf-with-js-technbuzz.com_-768x582.png 768w" sizes="(max-width: 1009px) 100vw, 1009px" /></a></figure>



<p>Our first version will just accept file and display it as it is. So let&#8217; prepare some HTML for it</p>



<h3 class="wp-block-heading">The template</h3>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-html"><code>&lt;main&gt;
  &lt;input id="fileInput" type="file" accept=".pdf" /&gt;
&lt;/main&gt;
&lt;output&gt;
  &lt;iframe&gt; &lt;/iframe&gt;
&lt;/output&gt;
&lt;script type="module" src="/src/main.ts"&gt;&lt;/script&gt;</code></pre></div>



<p>We added some basic input element to grab file and iframe to view it. Let&#8217;s go to the implementation part.</p>



<h3 class="wp-block-heading">Base Styles</h3>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-css"><code>html, body {
  height: 100%;
}

body {
  display: grid;
  grid-template-rows: auto 1fr;
}

iframe {
  width: 100%;
  height: 100%;
}

input[type='file'] {
  outline: 1px dashed grey;
  padding: 2rem;
}</code></pre></div>



<p>We added some styles for base layout. The iframe comes with default dimension which is very small to render the pdf file. So we will set to take all the available space of it&#8217;s parent element.</p>



<h3 class="wp-block-heading">Display file</h3>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-js"><code>const fileInput = document.querySelector('input[type="file"]')
const iframe = document.querySelector('iframe')</code></pre></div>



<p>We are getting reference of those element in JavaScript.</p>



<div class="wp-block-create-block-prism-block"><pre data-line="6" class="language-js line-numbers"><code>fileInput.addEventListener('change', event =&gt; {
  const file = (event.target as HTMLInputElement).files[0]
  const reader = new FileReader()

  reader.onload = async () =&gt; {
    iframe.src = reader.result
  }

  reader.readAsDataURL(file)
})
</code></pre></div>



<p>On file change aka file upload we use file reader to read it as <a href="https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL" type="link" id="https://developer.mozilla.org/en-US/docs/Web/API/FileReader/readAsDataURL" target="_blank" rel="noreferrer noopener">DataURL</a>. Then on line 6 we are setting iframe source to <em>reader result.</em></p>



<h3 class="wp-block-heading">Output</h3>



<figure class="wp-block-image size-large"><a href="https://www.technbuzz.com/wp-content/uploads/2026/05/sample-output-of-pdf-viewer-technbuzz.com_.jpg"><img decoding="async" width="1024" height="707" src="https://www.technbuzz.com/wp-content/uploads/2026/05/sample-output-of-pdf-viewer-technbuzz.com_-1024x707.jpg" alt="Screenshot of the sample pdf viewer that we have achieved so far in this tutorial" class="wp-image-3641" srcset="https://www.technbuzz.com/wp-content/uploads/2026/05/sample-output-of-pdf-viewer-technbuzz.com_-1024x707.jpg 1024w, https://www.technbuzz.com/wp-content/uploads/2026/05/sample-output-of-pdf-viewer-technbuzz.com_-300x207.jpg 300w, https://www.technbuzz.com/wp-content/uploads/2026/05/sample-output-of-pdf-viewer-technbuzz.com_-768x530.jpg 768w, https://www.technbuzz.com/wp-content/uploads/2026/05/sample-output-of-pdf-viewer-technbuzz.com_-1536x1060.jpg 1536w, https://www.technbuzz.com/wp-content/uploads/2026/05/sample-output-of-pdf-viewer-technbuzz.com_-2048x1413.jpg 2048w, https://www.technbuzz.com/wp-content/uploads/2026/05/sample-output-of-pdf-viewer-technbuzz.com_-1200x828.jpg 1200w, https://www.technbuzz.com/wp-content/uploads/2026/05/sample-output-of-pdf-viewer-technbuzz.com_-1980x1366.jpg 1980w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure>



<p>As we can see the pdf viewer shows <em>1 of 2 pages</em>. This we don&#8217;t want.  We want one page for both faces of the page. </p>



<p>We have managed to build a simple input and output viewer.</p>



<h4 class="wp-block-heading">Implementation</h4>



<p>Next we need to involve the <em>pdf-lib</em>. We can achieve our target with following plan</p>



<ol class="wp-block-list">
<li>Load document in to pdf-lib </li>



<li>Extract pages 1 and 2 </li>



<li>Create a brand new document</li>



<li>Create new page and embed page 1 as top half in newly create page</li>



<li>Embed the page 2 as bottom half of the newly created page</li>



<li>Save document and update the viewer</li>
</ol>



<h5 class="wp-block-heading">1. Load document in pdf-lib</h5>



<h5 class="wp-block-heading">2. Extract pages 1 and 2</h5>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-js line-numbers"><code>import { PageSizes, PDFDocument, PDFPage } from 'pdf-lib'

fileInput.addEventListener('change', event =&gt; {
  //...
  reader.onload = async () =&gt; {

    const doc = await PDFDocument.load(reader.result)
    firstPage= doc.getPage(0);
    secondPage = doc.getPage(1)
    createDocument(firstPage, secondPage)
  }

  reader.readAsArrayBuffer(file)
})
</code></pre></div>



<p>First of all we are reading file as <em>arrayBuffer</em> that is what accepted format on <strong>line 7</strong>. On next two lines we extract first and last page. We hand over control to <code>createDocument</code> <em>function</em></p>



<h5 class="wp-block-heading">3. Create a brand new document</h5>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-js"><code>async function createDocument(pageAToEmbed: PDFPage, pageBToEmbed: PDFPage) {
  const doc = await PDFDocument.create()

  const embeddedPageA = await doc.embedPage(pageAToEmbed)
  const embeddedPageB = await doc.embedPage(pageBToEmbed)
</code></pre></div>



<p>We start the <code>async createDocument</code> function with creating a brand new document. Next we need to convert the extracted pages in previous code snippets in to embeddable pages. We have references for both of them</p>



<h5 class="wp-block-heading">4. Create new page and embed page 1 as top half in newly create page</h5>



<h5 class="wp-block-heading">5. Embed the page 2 as bottom half of the newly created page</h5>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-js line-numbers"><code>  const page = doc.addPage()
  let [width ,height] = PageSizes.A4

  page.drawPage(embeddedPageA, { x: 10, y: height/2, width: width, height: height/2 })

  page.drawPage(embeddedPageB, { x: 10, y: 0, width, height: height/2 })
</code></pre></div>



<p>Next we need to create a brand new page. On <strong>line 2</strong> we have <em>width x height</em> for <strong>A4</strong> page. That will be used as dimension calculation later. </p>



<p>On <strong>line 4</strong> there is one important detail, x and y axis doesn&#8217;t start from top left. I think they start from bottom left. So I have to move the <em>y axis</em> to middle of the page. This way the first page is rendered on top half part of the new page.</p>



<p>Same thing happens on <strong>line 6</strong> , but this time we move the <em>y axis</em> to 0 which means bottom of the page. When embedded page is drawn it appears on bottom of page.</p>



<h5 class="wp-block-heading">6. Save pdf document and update the viewer</h5>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="javascript"><code>  const bytes = await doc.save()
  iframe.src = `data:application/pdf;base64,${bytes.toBase64()}`
}
</code></pre></div>



<p> We have reached to final lines in the our <code>createDocument</code> function. The <strong>line 1</strong> returns the <code>Uint8Array</code> . In the next line we are prepend it with proper <a href="https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data" type="link" id="https://developer.mozilla.org/en-US/docs/Web/URI/Reference/Schemes/data">data: URL</a> with proper media type and assign it as the <em>source of our iframe</em>. And the result becomes</p>



<figure class="wp-block-image size-large"><a href="https://www.technbuzz.com/wp-content/uploads/2026/05/output-single-pdf-technbuzz.com_-scaled.jpg"><img loading="lazy" decoding="async" width="1024" height="532" src="https://www.technbuzz.com/wp-content/uploads/2026/05/output-single-pdf-technbuzz.com_-1024x532.jpg" alt=" This is the final result we get, an image that show when we import pdf and after going through process via pdf-lib we get single page pdf of two page pdfs" class="wp-image-3649" srcset="https://www.technbuzz.com/wp-content/uploads/2026/05/output-single-pdf-technbuzz.com_-1024x532.jpg 1024w, https://www.technbuzz.com/wp-content/uploads/2026/05/output-single-pdf-technbuzz.com_-300x156.jpg 300w, https://www.technbuzz.com/wp-content/uploads/2026/05/output-single-pdf-technbuzz.com_-768x399.jpg 768w, https://www.technbuzz.com/wp-content/uploads/2026/05/output-single-pdf-technbuzz.com_-1536x798.jpg 1536w, https://www.technbuzz.com/wp-content/uploads/2026/05/output-single-pdf-technbuzz.com_-2048x1064.jpg 2048w, https://www.technbuzz.com/wp-content/uploads/2026/05/output-single-pdf-technbuzz.com_-1200x624.jpg 1200w, https://www.technbuzz.com/wp-content/uploads/2026/05/output-single-pdf-technbuzz.com_-1980x1029.jpg 1980w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></figure>



<p>As we you can see page <strong><em>1 of 1</em> </strong>which indicates we have successfully managed to convert two page pdf to single page pdf with both halves of identity card in one page.</p>



<p>This is ready to be transported or printed.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>We have managed to create a final version using pdf-lib library. We started with very basic version. We improved it step by step. I have personally learned how valuable iframe is as part of web platform. It provides so much out of the box which requires very minimum to set it up.</p>
<p>The post <a href="https://www.technbuzz.com/2026/05/23/pdf-two-page-to-single-page-in-javascript-pdf-lib/">Combine Two PDF Pages into One with pdf-lib</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.technbuzz.com/2026/05/23/pdf-two-page-to-single-page-in-javascript-pdf-lib/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3631</post-id>	</item>
		<item>
		<title>When to use Signals in Angular &#8211; Decision Tree</title>
		<link>https://www.technbuzz.com/2026/04/29/when-to-use-signal-in-angular-decision-tree/</link>
					<comments>https://www.technbuzz.com/2026/04/29/when-to-use-signal-in-angular-decision-tree/#respond</comments>
		
		<dc:creator><![CDATA[Samiullah Khan]]></dc:creator>
		<pubDate>Wed, 29 Apr 2026 17:09:22 +0000</pubDate>
				<category><![CDATA[Opinions]]></category>
		<category><![CDATA[control flow]]></category>
		<category><![CDATA[decision tree]]></category>
		<category><![CDATA[linkedSignal]]></category>
		<category><![CDATA[mermaid]]></category>
		<category><![CDATA[signals]]></category>
		<guid isPermaLink="false">https://www.technbuzz.com/?p=3613</guid>

					<description><![CDATA[<p>The content discusses a problem with resetting and syncing cascading dropdowns in Angular, where changing a root dropdown unintentionally resets a third dropdown. The solution involved moving the reset logic to the linkedSignal, illustrated through a flowchart and decision tree outlining various signal handling strategies in React.</p>
<p>The post <a href="https://www.technbuzz.com/2026/04/29/when-to-use-signal-in-angular-decision-tree/">When to use Signals in Angular &#8211; Decision Tree</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>I found this nice flow chart from the <a href="https://www.youtube.com/watch?v=XWz8pxQWD8c" target="_blank" rel="noreferrer noopener">video of Deborah Kurata </a>Youtube Channel</p>



<figure class="wp-block-image size-large"><a href="https://www.technbuzz.com/wp-content/uploads/2026/04/when-to-use-signal-angular-technbuzz.com_.jpg"><img loading="lazy" decoding="async" width="1024" height="851" src="https://www.technbuzz.com/wp-content/uploads/2026/04/when-to-use-signal-angular-technbuzz.com_-1024x851.jpg" alt="" class="wp-image-3615" srcset="https://www.technbuzz.com/wp-content/uploads/2026/04/when-to-use-signal-angular-technbuzz.com_-1024x851.jpg 1024w, https://www.technbuzz.com/wp-content/uploads/2026/04/when-to-use-signal-angular-technbuzz.com_-300x249.jpg 300w, https://www.technbuzz.com/wp-content/uploads/2026/04/when-to-use-signal-angular-technbuzz.com_-768x638.jpg 768w, https://www.technbuzz.com/wp-content/uploads/2026/04/when-to-use-signal-angular-technbuzz.com_-1536x1276.jpg 1536w, https://www.technbuzz.com/wp-content/uploads/2026/04/when-to-use-signal-angular-technbuzz.com_-1200x997.jpg 1200w, https://www.technbuzz.com/wp-content/uploads/2026/04/when-to-use-signal-angular-technbuzz.com_.jpg 1608w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></figure>



<p>I was having issue in resetting and syncing state for cascade drop downs. Where on changing a root dropdown would reset the third drop down in the chain.</p>



<p>I was doing bunch of signal rest explicitly on change of the first drop down linked signal. All I had to do is move reset logic to linkedSignal.</p>



<p>Here is the mermaid diagram of the decision tree</p>



<pre class="wp-block-preformatted">flowchart TD<br>    A[React to Signal\n Changes]<br>    A --> |No| B[Use a regular\n function]<br>    A --> |Yes| C[Set a readonly\n signal?]<br>    C --> |Yes| D["Use computed()" ] <br>    C --> |No| E[Set a writable \n signal?]<br>    E --> |Yes| F["Use linkedSignal()"]<br>    E --> |No| G[Perform an async \n operation?]<br>    G --> |Yes| H["Use resource() \n on rxResource()"]<br>    G --> |No| I["Use an effect()"]</pre>



<p>An ascii tree would look like</p>



<pre class="wp-block-preformatted overflow-auto">React to Signal Changes?<br>├── No<br>│   └── Use a regular function<br>└── Yes<br>    └── Set a readonly signal?<br>        ├── Yes<br>        │   └── Use computed()<br>        └── No<br>            └── Set a writable signal?<br>                ├── Yes<br>                │   └── Use linkedSignal()<br>                └── No<br>                    └── Perform an async operation?<br>                        ├── Yes<br>                        │   └── resource()/rxResource()<br>                        └── No<br>                            └── Use an effect()<br></pre>
<p>The post <a href="https://www.technbuzz.com/2026/04/29/when-to-use-signal-in-angular-decision-tree/">When to use Signals in Angular &#8211; Decision Tree</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.technbuzz.com/2026/04/29/when-to-use-signal-in-angular-decision-tree/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3613</post-id>	</item>
		<item>
		<title>Understanding Angular Checkbox Directives and Host Binding</title>
		<link>https://www.technbuzz.com/2026/04/07/narrow-type-angular-directive/</link>
					<comments>https://www.technbuzz.com/2026/04/07/narrow-type-angular-directive/#respond</comments>
		
		<dc:creator><![CDATA[Samiullah Khan]]></dc:creator>
		<pubDate>Tue, 07 Apr 2026 01:22:00 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Opinions]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[angular]]></category>
		<category><![CDATA[directive]]></category>
		<category><![CDATA[typescript]]></category>
		<guid isPermaLink="false">https://www.technbuzz.com/?p=3560</guid>

					<description><![CDATA[<p>Imagine we have directive that customizes the checkbox color and interaction. We want to make our checkbox checked base on certain condition. But line 5, the highlighted one will throw following error. What really happens is that Angular thinks we are binding directive on some host elements (container etc) that doesn&#8217;t have checked property. Angular [&#8230;]</p>
<p>The post <a href="https://www.technbuzz.com/2026/04/07/narrow-type-angular-directive/">Understanding Angular Checkbox Directives and Host Binding</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Imagine we have directive that customizes the checkbox color and interaction.</p>



<div class="wp-block-create-block-prism-block"><pre data-line="" class="language-js line-numbers"><code>import { Directive } from '@angular/core';

@Directive({
  selector: '[tnb-checkbox]',
})
export class TnbCheckbox {  
}
</code></pre></div>



<p>We want to make our checkbox <code>checked</code> base on certain condition.  </p>



<div class="wp-block-create-block-prism-block"><pre data-line="5" class="language-js line-numbers"><code>import { Directive } from '@angular/core';

@Directive({
  selector: '[tnb-checkbox]',
  '[checked]: 'isAllChecked()'
})
export class TnbCheckbox { 
  isAllChecked() {

  } 
}
</code></pre></div>



<p>But line 5, the highlighted one will throw following error. </p>



<figure class="wp-block-image size-large"><a href="https://www.technbuzz.com/wp-content/uploads/2026/04/image.png"><img loading="lazy" decoding="async" width="1024" height="114" src="https://www.technbuzz.com/wp-content/uploads/2026/04/image-1024x114.png" alt="An error by Angular Compiler 

Can't bind to 'checked' since it isn't a known property of 'ng-directive'." class="wp-image-3597" srcset="https://www.technbuzz.com/wp-content/uploads/2026/04/image-1024x114.png 1024w, https://www.technbuzz.com/wp-content/uploads/2026/04/image-300x33.png 300w, https://www.technbuzz.com/wp-content/uploads/2026/04/image-768x86.png 768w, https://www.technbuzz.com/wp-content/uploads/2026/04/image-1536x171.png 1536w, https://www.technbuzz.com/wp-content/uploads/2026/04/image-1200x134.png 1200w, https://www.technbuzz.com/wp-content/uploads/2026/04/image.png 1758w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a><figcaption class="wp-element-caption">Error message indicating an issue with binding the &#8216;checked&#8217; property in Angular directive.</figcaption></figure>



<p>What really happens is that Angular thinks we are binding directive on some host elements (container etc) that doesn&#8217;t have checked property.</p>



<p>Angular couldn&#8217;t determine the host is input checkbox, it treats the host as generic element. </p>



<p>But we can solve it by applying constraints to the selector, If our selector targets an actual <code>&lt;input type="checkbox></code> </p>



<div class="wp-block-create-block-prism-block"><pre data-line="4" class="language-js line-numbers"><code>import { Directive } from '@angular/core';

@Directive({
  selector: '[tnb-checkbox]input[type="checkbox"]',
  '[checked]: 'isAllChecked()'
})
export class TnbCheckbox { 
  isAllChecked() {

  } 
}</code></pre></div>



<p>With the selector, Angular knows the host element is <code>&lt;input></code> (specifically a checkbox). The DOM type <strong>HTMLInputElement</strong> does have <strong>checked</strong> attribute (along with others properties like intermediate)</p>



<p>Angular template checking is type aware. Since <a href="https://blog.angular.dev/announcing-angular-v20-b5c9c06cf301">Angular Version 20</a>, the host binding is improved. We have type checking for host binding and listener expressions. </p>



<p>It will be really interesting to find out how the compound selector string is translated to host binding type checking.</p>



<p></p>
<p>The post <a href="https://www.technbuzz.com/2026/04/07/narrow-type-angular-directive/">Understanding Angular Checkbox Directives and Host Binding</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.technbuzz.com/2026/04/07/narrow-type-angular-directive/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3560</post-id>	</item>
		<item>
		<title>Tailwind Arbitrary classes  in Angular host properties</title>
		<link>https://www.technbuzz.com/2026/02/12/tailwind-arbitrary-classes-in-angular-host-properties/</link>
					<comments>https://www.technbuzz.com/2026/02/12/tailwind-arbitrary-classes-in-angular-host-properties/#respond</comments>
		
		<dc:creator><![CDATA[Samiullah Khan]]></dc:creator>
		<pubDate>Thu, 12 Feb 2026 07:17:00 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[host]]></category>
		<category><![CDATA[tailwind]]></category>
		<category><![CDATA[utility-class]]></category>
		<guid isPermaLink="false">https://www.technbuzz.com/?p=3546</guid>

					<description><![CDATA[<p>I wanted to add different classes to the host element based on certain condition. I could add the classes in the accompanying style file. However, they won&#8217;t be available to be used on the host element. Unless I change the encapsulation mode to ViewEncapsulation.None. That removes the encapsulation and make the style declarations global. Which [&#8230;]</p>
<p>The post <a href="https://www.technbuzz.com/2026/02/12/tailwind-arbitrary-classes-in-angular-host-properties/">Tailwind Arbitrary classes  in Angular host properties</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>I wanted to add different classes to the host element based on certain condition. I could add the classes in the accompanying style file. However, they won&#8217;t be available to be used on the host element.</p>



<p>Unless I change the encapsulation mode to <a href="https://angular.dev/api/core/ViewEncapsulation" target="_blank" rel="noreferrer noopener">ViewEncapsulation.None</a>. That removes the encapsulation and make the style declarations global. Which may not be intended behavior. </p>



<p>But we can use Tailwind <a href="https://tailwindcss.com/docs/styling-with-utility-classes#using-arbitrary-values">arbitrary classes</a>. This way angular directly adds those classes to element. While tailwind classes are global for the entire project so everything works.</p>



<p>But</p>



<p>Tailwind arbitrary class does not work with angular host properties</p>


<pre id="" class="Yes" data-line="">
    <code class="language-js">host: {
    class: 'overflow-auto grid',
    '[class.grid-rows-[auto_min-content_auto] ]': 'isFilterVisible',
    '[class.grid-rows-[auto_min-content] ]': '!isFilterVisible',
  }</code>
</pre>


<p>This end up in generating following classes</p>


<pre id="" class="No" data-line="">
    <code class="language-markup">&lt;my-component class=&quot;grid grid-rows-[auto_min-content\&quot; &gt;&lt;/my-component&gt;</code>
</pre>


<p>We are missing the closing bracket of the arbitrary classes. Tailwind won&#8217;t recognize it and will not create a CSS declaration  bead on that.</p>



<p>Escaping the the extra bracket has no effects either</p>


<pre id="" class="Yes" data-line="">
    <code class="language-js">host: {
    class: 'overflow-auto grid',
    '[class.grid-rows-[auto_min-content_auto\\] ]': 'isFilterVisible',
    '[class.grid-rows-[auto_min-content\\] ]': '!isFilterVisible',
  }</code>
</pre>


<h3 class="wp-block-heading">Solution</h3>



<p>The solution is to use Component class properties that returns appropriate classes in object</p>


<pre id="" class="Yes" data-line="">
    <code class="language-js">@Component({
  host: {
      class: 'overflow-auto grid',
      '[class]': 'gridClasses()',
    }
})
export class MyComponent {
  gridClasses = computed(() =&gt; {

    return {
      'grid-rows-[auto_min-content_auto]': this.isFilterVisible(),
      'grid-rows-[auto_min-content]': !this.isFilterVisible()
    }
  })
}</code>
</pre>


<p></p>
<p>The post <a href="https://www.technbuzz.com/2026/02/12/tailwind-arbitrary-classes-in-angular-host-properties/">Tailwind Arbitrary classes  in Angular host properties</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.technbuzz.com/2026/02/12/tailwind-arbitrary-classes-in-angular-host-properties/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3546</post-id>	</item>
		<item>
		<title>Nice usage of rediretFunction in Angular Router</title>
		<link>https://www.technbuzz.com/2026/02/01/nice-usage-of-redirectfunction-in-angular-router/</link>
					<comments>https://www.technbuzz.com/2026/02/01/nice-usage-of-redirectfunction-in-angular-router/#respond</comments>
		
		<dc:creator><![CDATA[Samiullah Khan]]></dc:creator>
		<pubDate>Sun, 01 Feb 2026 09:54:40 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Tutorials]]></category>
		<guid isPermaLink="false">https://www.technbuzz.com/?p=3541</guid>

					<description><![CDATA[<p>The rediretTo property in the Router now accepts a function since version 18. That can return a string or UrlTree. I have found one nice use case for it. Imagine you have following routes Here when we visit the /users we are redirected to /users/list. Now you are asked to create one more entry in [&#8230;]</p>
<p>The post <a href="https://www.technbuzz.com/2026/02/01/nice-usage-of-redirectfunction-in-angular-router/">Nice usage of rediretFunction in Angular Router</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>The <code>rediretTo</code> property in the Router now accepts a function since <a href="https://github.com/angular/angular/releases/tag/18.0.0">version 18</a>. That can return a string or UrlTree. </p>



<p>I have found one nice use case for it.</p>



<p>Imagine you have following routes</p>


<pre id="" class="Yes" data-line="">
    <code class="language-">{
  path: 'users',
  children: [
    { path: '', redirectTo: 'list', pathMatch: 'full' },
    { path: 'list', component: UserList },
    { path: 'settings', component: UserSettings },
  ]
}</code>
</pre>


<p>Here when we visit the <code>/users</code> we are redirected to <code>/users/list</code>.</p>



<p>Now you are asked to create one more entry in the users page, that is <strong>Overview Page</strong>.</p>



<p>Now this page should be under a feature flag or we protect it for some users. The update routes would look like this </p>



<p></p>
<p>The post <a href="https://www.technbuzz.com/2026/02/01/nice-usage-of-redirectfunction-in-angular-router/">Nice usage of rediretFunction in Angular Router</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.technbuzz.com/2026/02/01/nice-usage-of-redirectfunction-in-angular-router/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3541</post-id>	</item>
		<item>
		<title>How I fixed Nvim icons</title>
		<link>https://www.technbuzz.com/2026/01/15/how-i-fixed-nvim-icons/</link>
					<comments>https://www.technbuzz.com/2026/01/15/how-i-fixed-nvim-icons/#respond</comments>
		
		<dc:creator><![CDATA[Samiullah Khan]]></dc:creator>
		<pubDate>Thu, 15 Jan 2026 08:24:01 +0000</pubDate>
				<category><![CDATA[Nvim]]></category>
		<category><![CDATA[jetbrains]]></category>
		<category><![CDATA[neovim]]></category>
		<category><![CDATA[nerd font]]></category>
		<category><![CDATA[nvim]]></category>
		<category><![CDATA[vim]]></category>
		<guid isPermaLink="false">https://www.technbuzz.com/?p=3533</guid>

					<description><![CDATA[<p>The CSS icons wasn&#8217;t showing in neo-tree so does the storybook icon. It was annoying to click to .stories.ts file mistakenly instead of .component.ts file. Neo-tree or entire nevoid space uses nvim-web-devicons which expect patched Nerd Font. Turns out I was using Liga SFMono Nerd Font Instead I chose JetBrainsMono Nerd Font It just had [&#8230;]</p>
<p>The post <a href="https://www.technbuzz.com/2026/01/15/how-i-fixed-nvim-icons/">How I fixed Nvim icons</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>The CSS icons wasn&#8217;t showing in <strong>neo-tree</strong> so does the storybook  icon. It was annoying to click to .stories.ts file mistakenly instead of <code>.component.ts</code> file.</p>



<p>Neo-tree or entire nevoid space uses <a href="https://github.com/nvim-tree/nvim-web-devicons">nvim-web-devicons</a> which expect patched Nerd Font.</p>



<p>Turns out I was using <strong>Liga SFMono Nerd Font</strong></p>



<ol class="wp-block-list">
<li>It isn&#8217;t officially patched, it&#8217;s community patched version</li>



<li>It has ligatures but not completely icon set</li>



<li>it predated Nerd fonts v2.3</li>
</ol>



<p>Instead I chose <a href="https://www.nerdfonts.com/font-downloads">JetBrainsMono Nerd Font</a></p>



<p>It just had to specify it to in the <strong>alacritty</strong> config at <code>.config/alacritty/.alacritty.toml</code></p>


<pre id="" class="Yes" data-line="">
    <code class="language-">[font.normal]
family = "JetBrainsMono Nerd Font"
style = "Regular"

[font.bold]
family = "JetBrainsMono Nerd Font"
style = "Bold"

[font.italic]
family = "JetBrainsMono Nerd Font"
style = "Italic"

[font.bold_italic]
family = "JetBrainsMono Nerd Font"
style = "Bold Italic"
</code>
</pre><p>The post <a href="https://www.technbuzz.com/2026/01/15/how-i-fixed-nvim-icons/">How I fixed Nvim icons</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.technbuzz.com/2026/01/15/how-i-fixed-nvim-icons/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3533</post-id>	</item>
		<item>
		<title>Accessibility and test hooks for HTM L Table</title>
		<link>https://www.technbuzz.com/2025/10/23/accessibility-and-test-hooks-for-table-cell/</link>
					<comments>https://www.technbuzz.com/2025/10/23/accessibility-and-test-hooks-for-table-cell/#respond</comments>
		
		<dc:creator><![CDATA[Samiullah Khan]]></dc:creator>
		<pubDate>Thu, 23 Oct 2025 05:53:00 +0000</pubDate>
				<category><![CDATA[Opinions]]></category>
		<category><![CDATA[accessiblity]]></category>
		<category><![CDATA[html]]></category>
		<guid isPermaLink="false">https://www.technbuzz.com/?p=3517</guid>

					<description><![CDATA[<p>Well usually you would use role attributes or aria-label or aria-labelled-by to add the accessibility heuristics. But in the case of table, you don&#8217;t need to add any thing extra to make the HTML Table accessible. Just using correct element syntax is enough. What it has to do with testing, well those can easily by [&#8230;]</p>
<p>The post <a href="https://www.technbuzz.com/2025/10/23/accessibility-and-test-hooks-for-table-cell/">Accessibility and test hooks for HTM L Table</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Well usually you would use role attributes or aria-label or aria-labelled-by to add the accessibility heuristics. But in the case of table, you don&#8217;t need to add any thing extra to make the HTML Table accessible. Just using correct element syntax is enough.</p>



<p>What it has to do with testing, well those can easily by used as locators or hooks that can be accessed by <a href="https://www.cypress.io/">cypress</a> or <a href="https://playwright.dev/">playwright</a> </p>



<p>So what options do we have with </p>


<pre id="" class="Yes" data-line="">
    <code class="language-markup">&lt;th&gt; User Name &lt;/th&gt;
&lt;&gt;....................&lt;/&gt;

&lt;td&gt;John Doe&lt;/td&gt;</code>
</pre>


<p>We can&#8217;t use <strong>id</strong> as this has to unique per element. The other options is to use <strong>cy-testId</strong> or some playwright equivalent. </p>



<p>The only caveat is we are locking ourselves in a particular system. In the future there is will be new testing library. </p>



<p>For future friendly solution we use custom attributes, that can be prefixed with data as </p>



<pre class="wp-block-code"><code>data-testId="username" </code></pre>



<h3 class="wp-block-heading">Bonus Tip:</h3>



<p>In angular we use pipes to transform values for display purpose only. </p>


<pre id="" class="Yes" data-line="">
    <code class="language-">&lt;p&gt; {{ 128.23423 | number: '1.0.1' }} &lt;/p&gt;</code>
</pre>


<p>This snippet is using <a href="https://angular.dev/api/common/DecimalPipe">Decimal Pipe</a> from angular. Writing end to end test in this case would require to round off value on both ends for reconcilleation. Or we can use yet another custom attribute to expose raw value</p>


<pre id="" class="Yes" data-line="">
    <code class="language-">&lt;td [attr.data-raw]="128.23423" data-testId="revenue" &gt; {{ 128.23423 | number: '1.0.1' }} &lt;td&gt;</code>
</pre>


<p>This way we are not bound to have any HTML structure inside the td. You can add icons and nested div and span tags to format the text and your test locators will still find the right element and text to do the comparison </p>
<p>The post <a href="https://www.technbuzz.com/2025/10/23/accessibility-and-test-hooks-for-table-cell/">Accessibility and test hooks for HTM L Table</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.technbuzz.com/2025/10/23/accessibility-and-test-hooks-for-table-cell/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3517</post-id>	</item>
		<item>
		<title>One less effect to reset signal in Angular</title>
		<link>https://www.technbuzz.com/2025/08/05/one-less-effect-to-reset-signal-in-angular/</link>
					<comments>https://www.technbuzz.com/2025/08/05/one-less-effect-to-reset-signal-in-angular/#respond</comments>
		
		<dc:creator><![CDATA[Samiullah Khan]]></dc:creator>
		<pubDate>Tue, 05 Aug 2025 05:43:03 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Opinions]]></category>
		<guid isPermaLink="false">https://www.technbuzz.com/?p=3496</guid>

					<description><![CDATA[<p>I need to fetch some posts. We will use the httpResource. HttpClient returned observables but this one is reactive wrapper around HttpClient. The response we get is a signal. We can render the content in template as {{ content.value() }} But there is new inquiry. We need filter by specific user, No problem we can [&#8230;]</p>
<p>The post <a href="https://www.technbuzz.com/2025/08/05/one-less-effect-to-reset-signal-in-angular/">One less effect to reset signal in Angular</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>I need to fetch some posts. We will use the httpResource. HttpClient returned observables but this one is reactive wrapper around HttpClient. The response we get is a signal. </p>


<pre id="" class="Yes" data-line="">
    <code class="language-js">page = signal(0)

content = httpResource(() =&gt; ({
  url: 'https://jsonplaceholder.typicode.com/posts',
    params: {
      page: this.page()
    }
}));</code>
</pre>


<p>We can render the content in template as <code>{{ content.value() }}</code></p>



<p>But there is new inquiry.</p>



<p>We need filter by specific user, No problem we can pass params. The params will come from Router, which we can easily fetch with in our component by enabling <strong><a href="https://angular.dev/api/router/withComponentInputBinding">withComponentInputBinding</a></strong>. In short it binds Router state to the component input.</p>


<pre id="" class="Yes" data-line="">
    <code class="language-shell">https://localhost:4000/posts?userId=332</code>
</pre>


<p>Our component becomes</p>


<pre id="" class="Yes" data-line="4,11">
    <code class="language-js">import { input } from '@angular/core';

page = signal(0)
userId = input()

content = httpResource(
    () =&gt; ({
      url: 'https://jsonplaceholder.typicode.com/posts',
      params: {
        page: this.page(),
        userId: this.userId(),
     }
));</code>
</pre>


<p>We use <code>input</code> to get <strong>userId</strong> from route as signal which makes our content resource <em>reactive</em>. </p>



<h2 class="wp-block-heading">What happens when we change user?</h2>



<p>We get the new value for <strong>userId</strong> input, this will in turn re run the <strong>content</strong> httpResource. Our template will be updated. </p>



<p>We have pagination feature on the page to list user post, we have navigate to <em>page 6</em> of <strong>User A</strong>. Now we switched the to <strong>User B</strong>. We need to reset the page to <em>page 1</em>. </p>



<p>No problem we can easily do that using effect to react to signal and update another signal. </p>


<pre id="" class="Yes" data-line="">
    <code class="language-js">#resetPage = effect(() =&gt; {
  const user = this.userId()
  this.page.set(0)
})</code>
</pre>


<p>This ensures we have pagination reset to <em>page 1</em> when user selection is updated. </p>



<p>But there is caveat to our way of using effect. In fact angular docs on <a href="https://angular.dev/guide/signals#use-cases-for-effects">Use cases of effect</a> no where mentions to use effects just to update another signal. </p>



<p>Its best uses cases are DOM read writes, syncing local storage among others.</p>



<h3 class="wp-block-heading">What if we can stay in Signals land.</h3>



<p>Don&#8217;t worry Angular have a better solution in the form of LinkedSignal. A signal can derive a dependent and it the same time it can be write able.</p>


<pre id="" class="Yes" data-line="">
    <code class="language-js">page = linkedSignal({ 
  source: this.userId, 
  computation: () =&gt; 0 
})</code>
</pre>


<p>One less effect in our signal reactive paradigm. LinkedSignal is a missing puzzle. It gives the default value to page. We are allowed to change <strong>page</strong> on demand. When <strong>userId</strong> is updated the page is automatically reset to initial state.</p>
<p>The post <a href="https://www.technbuzz.com/2025/08/05/one-less-effect-to-reset-signal-in-angular/">One less effect to reset signal in Angular</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.technbuzz.com/2025/08/05/one-less-effect-to-reset-signal-in-angular/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3496</post-id>	</item>
		<item>
		<title>Walt Disney unique way of requesting input</title>
		<link>https://www.technbuzz.com/2024/10/06/walt-disney-unique-way-of-requesting-input/</link>
					<comments>https://www.technbuzz.com/2024/10/06/walt-disney-unique-way-of-requesting-input/#respond</comments>
		
		<dc:creator><![CDATA[Samiullah Khan]]></dc:creator>
		<pubDate>Sun, 06 Oct 2024 06:45:04 +0000</pubDate>
				<category><![CDATA[Opinions]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[workflow]]></category>
		<guid isPermaLink="false">https://www.technbuzz.com/2024/10/06/walt-disney-unique-way-of-requesting-input/</guid>

					<description><![CDATA[<p>The post <a href="https://www.technbuzz.com/2024/10/06/walt-disney-unique-way-of-requesting-input/">Walt Disney unique way of requesting input</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div class="wp-block-jetpack-story wp-story aligncenter" data-id="wp-story-3483-1" data-settings="{&#34;slides&#34;:[{&#34;alt&#34;:&#34;&#34;,&#34;caption&#34;:&#34;&#34;,&#34;id&#34;:&#34;3481&#34;,&#34;link&#34;:&#34;https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104372_05790931529327888818.jpg&#34;,&#34;mime&#34;:&#34;image/jpeg&#34;,&#34;type&#34;:&#34;image&#34;,&#34;url&#34;:&#34;https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104372_05790931529327888818.jpg&#34;,&#34;width&#34;:720,&#34;height&#34;:1280,&#34;srcset&#34;:&#34;https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104372_05790931529327888818.jpg 720w, https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104372_05790931529327888818-169x300.jpg 169w, https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104372_05790931529327888818-576x1024.jpg 576w&#34;,&#34;sizes&#34;:&#34;(max-width: 460px) 576w, (max-width: 614px) 768w, 120vw&#34;,&#34;title&#34;:&#34;wp_story1728197104372_05790931529327888818&#34;},{&#34;alt&#34;:&#34;&#34;,&#34;caption&#34;:&#34;&#34;,&#34;id&#34;:&#34;3482&#34;,&#34;link&#34;:&#34;https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104377_11326054520174433599.jpg&#34;,&#34;mime&#34;:&#34;image/jpeg&#34;,&#34;type&#34;:&#34;image&#34;,&#34;url&#34;:&#34;https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104377_11326054520174433599.jpg&#34;,&#34;width&#34;:720,&#34;height&#34;:1280,&#34;srcset&#34;:&#34;https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104377_11326054520174433599.jpg 720w, https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104377_11326054520174433599-169x300.jpg 169w, https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104377_11326054520174433599-576x1024.jpg 576w&#34;,&#34;sizes&#34;:&#34;(max-width: 460px) 576w, (max-width: 614px) 768w, 120vw&#34;,&#34;title&#34;:&#34;wp_story1728197104377_11326054520174433599&#34;}]}">
			<div class="wp-story-app">
				<div class="wp-story-display-contents" style="display: contents;">
					<a class="wp-story-container" href="https://www.technbuzz.com/2024/10/06/walt-disney-unique-way-of-requesting-input/?wp-story-load-in-fullscreen=true&amp;wp-story-play-on-load=true" title="Play story in new tab">
						<div class="wp-story-meta">
							<div class="wp-story-icon">
								<img loading="lazy" decoding="async" alt="Site icon" src="https://www.technbuzz.com/wp-content/uploads/2020/07/cropped-3-150x150.png" width="40" height="40">
							</div>
							<div>
								<div class="wp-story-title">
									Walt Disney unique way of requesting input
								</div>
							</div>
						</div>
						<div class="wp-story-wrapper">
							<div class="wp-story-slide" style="display: block;">
			<figure><img loading="lazy" decoding="async" width="360" height="640" src="https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104372_05790931529327888818-576x1024.jpg" class="wp-story-image wp-image-3481 wp-story-crop-wide" alt="" sizes="auto, (max-width: 460px) 576w, (max-width: 614px) 768w, 120vw" title="wp_story1728197104372_05790931529327888818" srcset="https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104372_05790931529327888818-576x1024.jpg 576w, https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104372_05790931529327888818-169x300.jpg 169w, https://www.technbuzz.com/wp-content/uploads/2024/10/wp_story1728197104372_05790931529327888818.jpg 720w" /></figure>
		</div>
						</div>
						<div class="wp-story-overlay">
							<div class="wp-story-embed-icon-expand">
				<svg class="gridicon gridicons-fullscreen" role="img" height="24" width="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
					<g>
						<path d="M21 3v6h-2V6.41l-3.29 3.3-1.42-1.42L17.59 5H15V3zM3 3v6h2V6.41l3.29 3.3 1.42-1.42L6.41 5H9V3zm18 18v-6h-2v2.59l-3.29-3.29-1.41 1.41L17.59 19H15v2zM9 21v-2H6.41l3.29-3.29-1.41-1.42L5 17.59V15H3v6z"></path>
					</g>
				</svg>
			</div>
						</div>
						<div class="wp-story-pagination wp-story-pagination-bullets">
			<div class="wp-story-pagination-bullet " aria-label="Go to slide 1">
			<div class="wp-story-pagination-bullet-bar"></div>
		</div>
<div class="wp-story-pagination-bullet " aria-label="Go to slide 2">
			<div class="wp-story-pagination-bullet-bar"></div>
		</div>
		</div>
					</a>
				</div>
			</div>
		</div><p>The post <a href="https://www.technbuzz.com/2024/10/06/walt-disney-unique-way-of-requesting-input/">Walt Disney unique way of requesting input</a> appeared first on <a href="https://www.technbuzz.com">Technbuzz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.technbuzz.com/2024/10/06/walt-disney-unique-way-of-requesting-input/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3483</post-id>	</item>
	</channel>
</rss>
