<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Raphaël Balet on Medium]]></title>
        <description><![CDATA[Stories by Raphaël Balet on Medium]]></description>
        <link>https://medium.com/@raphael.balet?source=rss-93039633564d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Y1q7LSiqSUqswNIya81sDA.jpeg</url>
            <title>Stories by Raphaël Balet on Medium</title>
            <link>https://medium.com/@raphael.balet?source=rss-93039633564d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 22:10:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raphael.balet/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to log in to a VPS and replace your SSH key on Mac]]></title>
            <link>https://medium.com/@raphael.balet/how-to-log-in-to-a-vps-and-replace-your-ssh-key-on-mac-21de5d5cacb7?source=rss-93039633564d------2</link>
            <guid isPermaLink="false">https://medium.com/p/21de5d5cacb7</guid>
            <category><![CDATA[vps]]></category>
            <category><![CDATA[ssh-keys]]></category>
            <dc:creator><![CDATA[Raphaël Balet]]></dc:creator>
            <pubDate>Tue, 17 Nov 2026 06:30:30 GMT</pubDate>
            <atom:updated>2026-11-17T06:30:30.226Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide takes about 7–11 minutes</p><p>You will connect to an Ubuntu VPS, create a new key on your Mac, test it, and revoke the old key. Keep the first connection open until the new key works and the old key is rejected.</p><p>The examples assume a direct SSH connection on port 22 and the username ubuntu. Replace server.example.com with your server’s hostname or IP address. If your provider uses another username, replace ubuntu too.</p><p>Your private key stays on your Mac. The server stores the matching public key in your account’s ~/.ssh/authorized_keys file. This guide uses that standard setup, described in the <a href="https://ubuntu.com/server/docs/how-to/security/openssh-server/">Ubuntu OpenSSH documentation</a>.</p><h3>1. Connect with your current key</h3><p>On your Mac, create a file for the existing private key. If you already have it saved locally, use its path in the SSH commands instead.</p><pre>mkdir -p ~/.ssh<br>chmod 700 ~/.ssh<br>umask 077<br>nano ~/.ssh/vps-old</pre><p>Paste the existing private key from your secure source. Include its BEGIN and END lines, preserving line breaks. Do not include Markdown backticks.</p><p>Save in nano: Ctrl+O, Enter, then Ctrl+X.</p><pre>chmod 600 ~/.ssh/vps-old<br>ssh -o IdentitiesOnly=yes -i ~/.ssh/vps-old ubuntu@server.example.com</pre><p>On a first connection, SSH may ask you to accept the server’s fingerprint. Compare it with a fingerprint obtained through your provider’s console or a trusted administrator before accepting. The server fingerprint is separate from your login key.</p><p>Once connected, check the account:</p><pre>whoami</pre><p>Expected output: ubuntu. Keep this terminal connected. From here on, call it tab 1: VPS.</p><h3>2. Generate a new key on your Mac</h3><p>Open a second Terminal tab with Cmd+T. This is tab 2: Mac. Generate the replacement key here:</p><pre>ssh-keygen -t ed25519 -f ~/.ssh/vps -C &quot;vps-access&quot;</pre><p>Choose a passphrase when prompted. It protects the private key file on your Mac. If the filename already exists, stop and choose another filename instead of overwriting it.</p><p>The command creates two files: ~/.ssh/vps is the private key; ~/.ssh/vps.pub is the public key. Only the public key goes onto the VPS. See the <a href="https://man.openbsd.org/ssh-keygen">ssh-keygen manual</a> for the options.</p><p>Copy the public key to your clipboard:</p><pre>pbcopy &lt; ~/.ssh/vps.pub</pre><h3>3. Add the new public key on the VPS</h3><p>Return to tab 1: VPS. Back up the current access list and open it:</p><pre>cp -p ~/.ssh/authorized_keys ~/.ssh/authorized_keys.before-rotation<br>nano ~/.ssh/authorized_keys</pre><p>Paste the new public key onto its own line. Keep all existing keys for now. Save with Ctrl+O, Enter, then Ctrl+X.</p><pre>chmod 600 ~/.ssh/authorized_keys</pre><p>Each entry authorizes a key for this account. Preserving the other entries keeps other users’ access intact.</p><h3>4. Test a fresh connection with the new key</h3><p>In tab 2: Mac, run:</p><pre>ssh -F /dev/null \<br>  -o IdentitiesOnly=yes \<br>  -o PreferredAuthentications=publickey \<br>  -i ~/.ssh/vps \<br>  ubuntu@server.example.com whoami</pre><p>Enter the new key’s passphrase if prompted. Expected output: ubuntu. The command then returns to your Mac prompt.</p><p>This test ignores your usual SSH configuration, including connection sharing, limits identities to the specified key, and prevents password fallback. These are <a href="https://man.openbsd.org/ssh_config">OpenSSH client options</a>. If you normally need a custom port or jump host, adapt the test to that connection setup.</p><p>If the test fails, stop here. Leave the old key in place and keep tab 1 connected while you resolve the failure.</p><h3>5. Revoke the old key and verify access</h3><p>In tab 1: VPS, reopen the access list:</p><pre>nano ~/.ssh/authorized_keys</pre><p>Delete only the entry matching the old public key. Match the key text, not just the email address or comment at the end. Keep your new key and any keys belonging to other users.</p><p>If you need to identify the old public key, derive it from the old private key in tab 2: Mac:</p><pre>ssh-keygen -y -f ~/.ssh/vps-old</pre><p>Compare that output with the entry before deleting it. Save your edit in tab 1 with Ctrl+O, Enter, then Ctrl+X.</p><p>In tab 2: Mac, repeat the new-key test from step 4. It must still print ubuntu. Then test the old key:</p><pre>ssh -F /dev/null \<br>  -o IdentitiesOnly=yes \<br>  -o PreferredAuthentications=publickey \<br>  -i ~/.ssh/vps-old \<br>  ubuntu@server.example.com whoami</pre><p>Expected result: Permission denied (publickey). A timeout or connection error does not prove that the key was revoked.</p><p>Once the new key works and the old key is rejected, delete the temporary private-key copy on your Mac:</p><pre>rm ~/.ssh/vps-old</pre><p>If the old private key was shared in a message, ticket, or document, remove it there too. Deleting that text alone does not revoke access: remove the old public key from every account and server where it was authorized.</p><p>For future logins, use:</p><pre>ssh -o IdentitiesOnly=yes -i ~/.ssh/vps ubuntu@server.example.com</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=21de5d5cacb7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Angular Architecture That Scales: Folder Structure Deep Dive]]></title>
            <link>https://javascript.plainenglish.io/an-angular-architecture-that-scales-folder-structure-deep-dive-5d5f6cd853e6?source=rss-93039633564d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d5f6cd853e6</guid>
            <category><![CDATA[code-organization]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[frontend]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[Raphaël Balet]]></dc:creator>
            <pubDate>Wed, 16 Apr 2025 06:29:26 GMT</pubDate>
            <atom:updated>2025-05-06T14:08:24.680Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Over six years ago, I read a great article by </em><a href="https://itnext.io/choosing-a-highly-scalable-folder-structure-in-angular-d987de65ec7"><em>Mathis Garberg</em></a><em> It provided a scalable and helpful approach for building both simple and complex projects with Angular. Since the article is now a bit dated, my goal here is to offer a fresh take on Angular folder structure.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*TyPRNotxr_qpgRt-ycU3qg.png" /></figure><p><em>This structure is published in the following </em><a href="https://github.com/o-pinion/angular/wiki/folder-structure"><em>open source repo</em></a><em>, Feel free to open an issue if you have any suggestions for improvement.</em></p><h3>Simple one page projects</h3><p>For such projects, the standard <a href="https://angular.dev/style-guide#overall-structural-guidelines">Angular structural guideline</a> is recommended. If the project grows in complexity over time, you can gradually adopt and extend it with the structure described below.</p><h3>Complex projects</h3><h4>Naming convention : Folders &amp; Files</h4><ol><li><strong>kebab-case</strong></li><li>should become <strong>increasingly more specific</strong> as you read from <strong>left to right</strong></li></ol><pre>// Example<br>src<br>└─+ app<br>    └─+ pages<br>       └─+ home<br>           ├── home.page.ts<br>           └─+ home-descriptipn<br>               └── home-description.component.ts</pre><h4><strong>The structure</strong></h4><p><em>Note: + indicates that the folder has additional files.</em></p><pre>public<br>├─+ fonts<br>├─+ i18n<br>├─+ icons<br>│   └── [name]-[direction]-[color].svg<br>├─+ img<br>│   └─+ components<br>│       └── [page, component, ...]-[name]<br>│           └── bg-desktop.jpg<br>│           └── bg-mobile.jpg<br>├─+ js<br>├─+ json<br>├─+ pdf<br>└─+ video<br><br>src<br>├─+ app<br>│   ├─+ pages<br>│   │   ├─+ auth<br>│   │   │   ├─+ login<br>│   │   │   ├─+ register<br>│   │   │   └─+ auth-layout<br>│   │   └─+ [page]<br>│   │       ├── [page].page.html<br>│   │       ├── [page].page.scss<br>│   │       ├── [page].page.ts<br>│   │       ├── [page].module.ts<br>│   │       └─+ [page]-[name]<br>│   │           ├── [page]-[name].component.html<br>│   │           ├── [page]-[name].component.scss<br>│   │           ├── [page]-[name].component.ts<br>│   │           ├── [page]-[name].module.ts<br>│   │           └─+ [components, modals, ...]<br>│   ├─+ configs<br>│   │   ├── [name].config.ts<br>│   │   └── global.config.ts<br>│   ├─+ core<br>│   │   ├─+ animations<br>│   │   │   └── global.ts<br>│   │   ├─+ interceptors<br>│   │   │   ├── version.interceptor.ts<br>│   │   │   └── auth.interceptor.ts<br>│   │   ├─+ guards<br>│   │   │   ├── auth.guard.ts<br>│   │   │   └── admin.guard.ts<br>│   │   ├─+ directives<br>│   │   │   └── validation.directive.ts<br>│   │   ├─+ services<br>│   │   │   ├── dal.service.ts<br>│   │   │   ├── session.service.ts<br>│   │   │   └── [another-api].service.ts<br>│   │   ├─+ bases<br>│   │   │   └── base-[type].[service, query, component].ts<br>│   │   └─+ models<br>│   │       ├── core.enums.ts<br>│   │       ├── core.d.ts // interfaces<br>│   │       └── core.models.ts<br>│   │       └── core.types.ts<br>│   └─+ shared<br>│       ├─+ components<br>│       │   └── [name]<br>│       │     └── [name].component.ts<br>│       ├─+ layouts<br>│       │   └── [name]<br>│       │     └── [name].layout.ts<br>│       ├─+ modals <br>│       │   └── [name]<br>│       │     └── [name].modals.ts<br>│       ├─+ pipes<br>│       │   └── [name]<br>│       │     └── [name].pipe.ts<br>│       ├─+ services<br>│       │   └── [name]<br>│       │     └── [name].service.ts<br>│       └─+ vendors<br>│           ├─+ components<br>│           │   └── [name].component.ts<br>│           └─+ layouts<br>│               └── [name].layout.ts<br>├─+ environments<br>│   ├── environment.prod.ts<br>│   └── environment.ts<br>└─+ styles<br>    ├─+ base<br>    │   ├── _colors.scss<br>    │   ├── _img.scss<br>    │   ├── _reset.scss<br>    │   └── _typography.scss<br>    ├─+ components<br>    │   ├── _buttons.scss<br>    │   └── _gallery.scss<br>    ├─+ themes<br>    │   ├── _admin.scss<br>    │   └── _theme.scss<br>    ├─+ utils<br>    │   ├── _functions.scss<br>    │   ├── _mixins.scss<br>    │   └── _variables.scss<br>    ├── _shared.scss<br>    └── main.scss</pre><h4><a href="https://github.com/o-pinion/angular/wiki/Folder-structure#logic-explanation">Logic explained</a></h4><pre>| folder          | description                                             |<br>| --------------- | ------------------------------------------------------- |<br>| **public**      | Contains static assets                                  |<br>| - i18n          | International language files                            |<br>| - icons         | Contains only .svg files                                |<br>| **pages**       | Contains different pages                                |<br>| - @pages        | Contains components                                     |<br>| - [page]        | Page name (ex: home, about)                             |<br>| - [page]-[name] | Contains the component                                  |<br>| **configs**     | Contains global logic, normally constant variables      |<br>| **core**        | App core logic                                          |<br>| - guards        | For restricted routes                                   |<br>| - store         | Storing values coming from the services                 |<br>| - services      | Getting values from an API or a Database                |<br>| - bases         | Intended to be extended (inheritance)                   |<br>| - models        |                                                         |<br>| - - enums       | Enumeration of constant variable                        |<br>| - - interfaces  | Contain globally used types                             |<br>| - - models      | Type that has function let var = new MyModel({})        |<br>| **shared**      | Used many times by different elements                   |<br>| - components    | Imported directly by the pages (ex: footer)             |<br>| - directives    | logic like longPress or other event listener            |<br>| - layouts       | Positioning of many components                          |<br>| - modals        | Reused modal                                            |<br>| - pipes         | Converting data directly inside the html                |<br>| - vendors       | Third-party code                                        |</pre><h4>Core vs Shared vs Children</h4><p><strong>Core</strong><br>Contains the code that is imported only once and used across the entire application</p><ul><li>Should be <strong>imported only once</strong>, <em>usually into the </em><em>app.module.ts</em></li><li>Services are <em>{provideIn: &#39;root&#39;} And therefore singletons</em></li></ul><p>Example: AppThemeService, SessionService, DarkModeService, ...</p><p><strong>Shared</strong><br>Meant to be <strong>imported multiple time</strong> across the project</p><p>Example: userService, labelService , ...</p><p><strong>Children<br></strong>Elements that are only <strong>used within a specific folder</strong> and <strong>not shared elsewhere</strong>.</p><pre>// Example: Auth might require its own dedicated layout<br>└─+ pages<br>    └─+ auth<br>        ├─ login<br>        │  └─ login.page.ts<br>        ├─ signup <br>        │  └─ signup.page.ts<br>        └─ layout  <br>           └─ auth.layout.ts</pre><h4>layouts &amp; pages: Why not components only</h4><p><em>Visual example available &gt; </em><a href="https://github.com/o-pinion/angular/wiki/component-page-layout"><em>here</em></a></p><p>In large-scale projects, the components folder can grow overwhelming very quickly.<br>To reduce complexity and improve maintainability, we divide components into distinct categories:</p><p><strong>Components<br></strong>What isn’t a page nor a layout</p><ul><li>Examples: Sidebar, Card, Table, ...</li><li>Naming convention:<br>File: sidebar.component.ts<br>Class: SidebarComponent</li></ul><p><strong>Pages<br></strong>Route destinations, typically mapped to URLs</p><ul><li>Examples: Home, Login, Blogs, ...</li><li>Naming convention:<br>File: home.page.ts<br>Class: HomePage</li></ul><p><strong>Layouts<br></strong>Define the structure and positioning of UI areas</p><ul><li>Examples: Main website layout (Sidenav, main content &amp; footer), Auth layout (logo &amp; Centered container) , Article (Header, Content), …</li><li>Naming convention:<br>File: main.layout.ts<br>Class: MainLayout</li></ul><h4>Etc…</h4><p>Logical elements can also be moved into their own dedicated folder if the project requires it.</p><p><em>Note: Avoid creating a logical folder if it would contain three or fewer components.</em></p><ul><li>Examples: modals, buttons, ...</li><li>Naming convention:<br>File: [name].[element].ts<br>Class: [Name][Element]</li></ul><h4>Summary</h4><p>I’ve done my best to be as exhaustive as my current knowledge allows. However, integrating additional libraries , such as NgRx, TanStack, and others, will inevitably require some adjustments to the architecture, though its core principles should remain largely the same.</p><p>If you have any suggestions that could help others, please feel free to open a <a href="https://github.com/o-pinion/angular/pulls">PR</a>.</p><p>Best regards</p><h4>Acknowledgments</h4><ul><li><a href="https://itnext.io/choosing-a-highly-scalable-folder-structure-in-angular-d987de65ec7">Mathis Garberg — How to define a highly scalable folder structure for your Angular project</a></li><li><a href="https://levelup.gitconnected.com/where-shall-i-put-that-core-vs-shared-module-in-angular-5fdad16fcecc">Radek Busa — “Where Shall I Put That?” — Core vs Shared Module in Angular</a></li><li><a href="https://angular.dev/style-guide#overall-structural-guidelines">Angular — overall-structural-guidelines</a></li></ul><h4>Helpfull links</h4><ul><li>TsConfig paths: <a href="https://github.com/o-pinion/angular/wiki/Folder-structure#tsconfig-paths">Settings example</a></li></ul><h3>Thank you for being a part of the community</h3><p><em>Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/@InPlainEnglish"><strong>YouTube</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a> | <a href="https://differ.blog/inplainenglish"><strong>Differ</strong></a> | <a href="https://twitch.tv/inplainenglish"><strong>Twitch</strong></a></li><li><a href="https://cofeed.app/"><strong>Check out CoFeed, the smart way to stay up-to-date with the latest in tech</strong></a> <strong>🧪</strong></li><li><a href="https://differ.blog/"><strong>Start your own free AI-powered blog on Differ</strong></a> 🚀</li><li><a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Join our content creators community on Discord</strong></a> 🧑🏻‍💻</li><li>For more content, visit <a href="https://plainenglish.io/"><strong>plainenglish.io</strong></a> + <a href="https://stackademic.com/"><strong>stackademic.com</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d5f6cd853e6" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/an-angular-architecture-that-scales-folder-structure-deep-dive-5d5f6cd853e6">An Angular Architecture That Scales: Folder Structure Deep Dive</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A clean way to handle href with Angular]]></title>
            <link>https://javascript.plainenglish.io/a-clean-way-to-handle-href-with-angular-741604e6a9ee?source=rss-93039633564d------2</link>
            <guid isPermaLink="false">https://medium.com/p/741604e6a9ee</guid>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[href]]></category>
            <category><![CDATA[angular-library]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[optimisation]]></category>
            <dc:creator><![CDATA[Raphaël Balet]]></dc:creator>
            <pubDate>Thu, 07 Nov 2024 10:57:42 GMT</pubDate>
            <atom:updated>2025-04-19T14:30:27.457Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, let’s explore the proper way to handle href in Angular using the e <a href="https://www.npmjs.com/package/ngx-href"><strong>ngx-href</strong></a><strong> </strong>library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*J2dettitPwDVHJW0L0w5hA.png" /><figcaption><a href="https://blog.angular.dev/angular-v17-2-is-now-available-596cbe96242d">https://blog.angular.dev/angular-v17-2-is-now-available-596cbe96242d</a></figcaption></figure><h4>What are we talking about:</h4><p>1. SEO &amp; External URLs<br>2. SPAM prevention<br>3. Scroll-to links<br>4. Optimisation<br>5. Usage<br>6. Contributing</p><h3>1: SEO &amp; External URLs</h3><p><strong>Challenge:</strong> If you want to use Angular’s Material button with an external URL, you may come across (click)=&quot;openUrl()&quot; solutions. However, while they work, they aren’t SEO-friendly since web crawlers don’t recognize these as valid links.</p><p><strong>Solution:</strong> Once the library and directive are installed, it’s as easy as using:</p><pre>&lt;button mat-button href=&quot;https://external-url.com&quot; target=&quot;_blank&quot; rel=&quot;noopener nofollow&quot;&gt;<br>  An external link<br>&lt;/button&gt;</pre><h3>2: SPAM Prevention</h3><p><strong>Challenge:</strong> Displaying emails or phone numbers can invite spam.</p><p><strong>Solution:</strong> The library obfuscates these href values until a user clicks on them.</p><pre>&lt;!-- Tel --&gt;<br>&lt;a href=&quot;tel:+41791112233&quot;&gt;<br>  +41791112233<br>&lt;/a&gt;<br><br>&lt;!-- Email --&gt;<br>&lt;a href=&quot;mailto:foobar@outlook.com&quot;&gt;<br>  foobar&amp;#64;outlook.com<br>&lt;/a&gt;</pre><p>The displayed link will look like foobar(at)outlook.com until clicked, helping reduce spam.</p><h3>3: Scroll-to Links</h3><p><strong>Challenge:</strong> You want links to navigate to a specific section of your website.</p><p><strong>Solution:</strong> Use the directive with internal anchor links:</p><pre>&lt;!-- Scroll --&gt;<br>&lt;a href=&quot;#myAnchor&quot;&gt;<br>  My scroll to anchor<br>&lt;/a&gt;<br><br>&lt;!-- Scroll in different page --&gt;<br>&lt;a href=&quot;/angular/router#link&quot;&gt;<br>  My internal link with anchor<br>&lt;/a&gt;</pre><p>To dynamically generate anchors, use the toAnchor pipe:</p><pre>&lt;!-- Just transform the title to anchor like string--&gt;<br>&lt;div [id]=&quot;my Title $%&quot;| toAnchor : false&quot;&gt; &lt;/div&gt;<br><br>&lt;!-- If an href has been previously triggered, scroll to this element --&gt;<br>&lt;div [id]=&quot;my Title $%&quot;| toAnchor&quot;&gt; &lt;/div&gt;</pre><p>You can also navigate programmatically with:</p><pre>&lt;button (click)=&quot;ngxHrefService.scrollTo(#myAnchor)&quot;&gt;<br>  Scroll to #myAnchor<br>&lt;/button&gt;</pre><h3>4: Optimisation</h3><p><strong>Challenge:</strong> Handling a mix of internal and external links dynamically in Angular.</p><p><strong>Solution:</strong> The ngx-href directive automatically differentiates between internal and external links, ensuring the proper use of routerLink to avoid unnecessary reloads.</p><pre>&lt;!-- Angular router for internal links --&gt;<br>&lt;a href=&quot;/my-page&quot;&gt;<br>  My internal link<br>&lt;/a&gt;<br>&lt;a href=&quot;https://my-website/my-page&quot;&gt;<br>  My internal link<br>&lt;/a&gt;<br><br>&lt;!-- External link --&gt;<br>&lt;a href=&quot;https://external-url.com&quot;&gt;<br>  An external link<br>&lt;/a&gt;</pre><h3>5. Usage</h3><p>You’re convinced ? Then let’s use this thing.</p><p><strong>Step 1:</strong> Install the library</p><pre>npm i ngx-href</pre><p><strong>Step 2:</strong> Configure (Optional)</p><pre>import { NgxHrefServiceProvider } from &#39;ngx-href&#39;<br><br>bootstrapApplication(AppComponent, {<br>  providers: [<br>    {<br>      provide: NgxHrefServiceProvider,<br>      useValue: {<br>      /** Default<br>       * avoidSpam=&quot;false&quot;<br>       * behavior=&quot;auto&quot;<br>       * block=&quot;start&quot;<br>       * inline=&quot;nearest&quot;<br>       * rel=undefined<br>       * retryTimeout=undefined<br>       * target=&quot;_self&quot;<br>       **/ <br>        avoidSpam: true,<br>        defaultRelAttr: &#39;&#39;,<br>        defaultTargetAttr: &#39;_blank&#39;,<br>        retryTimeout: 300,<br>      },<br>    },<br>  ],<br>}).catch((err) =&gt; console.error(err));</pre><p><strong>Step 3: </strong>Use</p><pre>// any-component.ts<br>import { NgxHrefDirective, ToAnchorPipe, NgxHrefService } from &#39;ngx-href&#39;<br><br>imports: [<br>  NgxHrefDirective, // `href=&quot;&quot;`<br>  ToAnchorPipe, // `| toAnchor`<br>  NgxHrefService, // `ngxHrefService.scrollTo()`<br>]</pre><pre>&lt;!-- Angular router --&gt;<br>&lt;a href=&quot;/angular/router/link&quot;&gt;<br>  My internal link<br>&lt;/a&gt;<br><br>&lt;!-- Or with a button --&gt;<br>&lt;button href=&quot;/angular/router/link&quot;&gt;<br>  My internal link<br>&lt;/button&gt;<br><br><br>&lt;!-- External link --&gt;<br>&lt;a href=&quot;https://external-url.com&quot;&gt;<br>  An external link<br>&lt;/a&gt;<br><br>&lt;!-- Tel --&gt;<br>&lt;a href=&quot;tel:+41791112233&quot;&gt;<br>  +41791112233<br>&lt;/a&gt;<br><br>&lt;!-- Email --&gt;<br>&lt;a href=&quot;foobar@outlook.com&quot;&gt;<br>  foobar&amp;#64;outlook.com<br>&lt;/a&gt;<br><br>&lt;!-- Scroll --&gt;<br>&lt;a href=&quot;#myAnchor&quot;&gt;<br>  My scroll to anchor<br>&lt;/a&gt;<br><br>&lt;!-- Scroll in different page --&gt;<br>&lt;a href=&quot;/angular/router#link&quot;&gt;<br>  My internal link with anchor<br>&lt;/a&gt;</pre><h3>6. Contributing</h3><p>If you notice any issues or have suggestions, feel free to <a href="https://github.com/rbalet/ngx-href/issues">open an issue</a>. I’m always happy to improve the library.</p><p>Thanks for reading, and happy coding!</p><h3>In Plain English 🚀</h3><p><em>Thank you for being a part of the </em><a href="https://plainenglish.io/"><strong><em>In Plain English</em></strong></a><em> community! Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a></li><li><a href="https://differ.blog/"><strong>Create a free AI-powered blog on Differ.</strong></a></li><li>More content at <a href="https://plainenglish.io/"><strong>PlainEnglish.io</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=741604e6a9ee" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/a-clean-way-to-handle-href-with-angular-741604e6a9ee">A clean way to handle href with Angular</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to go back to the previous page in Angular]]></title>
            <link>https://javascript.plainenglish.io/how-to-go-back-to-the-previous-page-in-angular-549c599247c3?source=rss-93039633564d------2</link>
            <guid isPermaLink="false">https://medium.com/p/549c599247c3</guid>
            <category><![CDATA[angular-library]]></category>
            <category><![CDATA[back-button]]></category>
            <category><![CDATA[browser-history]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Raphaël Balet]]></dc:creator>
            <pubDate>Tue, 05 Nov 2024 11:35:28 GMT</pubDate>
            <atom:updated>2025-04-18T07:26:29.148Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, let’s explore how to <strong>implement a back button in Angular</strong> that works like your web browser’s native back button, using the <a href="https://github.com/rbalet/ngx-back-button"><strong>ngx-back-button</strong></a> library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*E50Udz5pAzTDWOvPUw0NIA.png" /><figcaption><a href="https://blog.angular.dev/angular-v17-2-is-now-available-596cbe96242d">https://blog.angular.dev/angular-v17-2-is-now-available-596cbe96242d</a></figcaption></figure><h3>Why a library?</h3><p>Have you ever thought about:<br>1. How your <strong>browser history</strong> is managed? (e.g., right-clicking the back button in Chrome)<br>2. What happens if the <strong>browser history is empty</strong>?<br>3. What occurs if you try <strong>navigating back with</strong> an <strong>empty URL tree</strong>?</p><p>If you have, you may have implemented custom logics for handling these cases. If not, maybe you should ;)</p><p>Let’s see how it works</p><h3><strong>Usage</strong></h3><h4>Step 1: Install the library</h4><pre>npm i ngx-back-button</pre><h4>Step 2: (Optional) Configure</h4><pre>// main.ts<br>import { NgxBackButtonServiceProvider } from &#39;ngx-back-button&#39;<br><br>bootstrapApplication(AppComponent, {<br>  providers: [<br>    { // This is optional<br>      provide: NgxBackButtonServiceProvider,<br>      useValue: {<br>        rootUrl: &#39;/custom&#39;, // Or any custom root URL<br>        fallbackPrefix: &#39;/tabs&#39;, // For library users<br>      },<br>    },<br>  ],</pre><h4>Step 3: Use</h4><pre>// any-component.ts<br>import { NgxBackButtonDirective } from &#39;ngx-back-button&#39;<br><br>imports: [<br>  NgxBackButtonDirective,<br>]</pre><p><strong>Directive</strong>: Normal use</p><pre>&lt;button ngxBackButton&gt;<br>  Back button<br>&lt;/button&gt;</pre><p><strong>Directive</strong>: With Fallback<br><em>In case the user starts on a child page, specify a fallback URL</em></p><pre>&lt;button ngxBackButton=&quot;/login&quot;&gt;<br>  Back to login<br>&lt;/button&gt;</pre><p><strong>Service</strong>: <br><em>To handle back navigation programmatically</em></p><pre>import { NgxBackButtonService } from &#39;ngx-back-button&#39;<br><br>constructor(private _backButtonService: NgxBackButtonService) {}<br><br>goBack() {<br>  this._backButtonService.back()<br>}</pre><h4>Extra: Handling App Exit in Web Apps</h4><p>The back() method returns a boolean:<br>- <strong>True</strong>: if there are items in his internal browsing history<br>- <strong>False</strong>: if his history is empty</p><p>In a web app, this can be useful for <strong>deciding when to exit the app</strong>. <br>For example, if you’re using <a href="https://capacitorjs.com/">Capacitor</a> and <a href="https://ionicframework.com/">Ionic</a>:</p><pre>// app.component.ts<br>import { App } from &#39;@capacitor/app&#39;<br>import { Platform } from &#39;@ionic/angular/standalone&#39;<br>import { NgxBackButtonService } from &#39;ngx-back-button&#39;<br><br>constructor(<br>  private _platform: Platform,<br>  private _backButtonService: NgxcBackButtonService,<br>) {<br>  this._handleAppExit() {} <br>}<br><br>private _handleAppExit() {<br>  this._platform.backButton.subscribeWithPriority(-1, () =&gt; {<br>    if (!this._backButtonService.back()) {<br>      App.exitApp()<br>    }<br>  })<br>}</pre><h4>Contributing</h4><p>If you spot any mistakes or have suggestions, feel free to <a href="https://github.com/rbalet/ngx-back-button/issues">open an issue</a>. I’m more than happy to improve it.</p><p>Thanks for reading, and happy coding!</p><h3>In Plain English 🚀</h3><p><em>Thank you for being a part of the </em><a href="https://plainenglish.io/"><strong><em>In Plain English</em></strong></a><em> community! Before you go:</em></p><ul><li>Be sure to <strong>clap</strong> and <strong>follow</strong> the writer ️👏<strong>️️</strong></li><li>Follow us: <a href="https://x.com/inPlainEngHQ"><strong>X</strong></a> | <a href="https://www.linkedin.com/company/inplainenglish/"><strong>LinkedIn</strong></a> | <a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong>YouTube</strong></a> | <a href="https://discord.gg/in-plain-english-709094664682340443"><strong>Discord</strong></a> | <a href="https://newsletter.plainenglish.io/"><strong>Newsletter</strong></a> | <a href="https://open.spotify.com/show/7qxylRWKhvZwMz2WuEoua0"><strong>Podcast</strong></a></li><li><a href="https://differ.blog/"><strong>Create a free AI-powered blog on Differ.</strong></a></li><li>More content at <a href="https://plainenglish.io/"><strong>PlainEnglish.io</strong></a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=549c599247c3" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/how-to-go-back-to-the-previous-page-in-angular-549c599247c3">How to go back to the previous page in Angular</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>