<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Angular on Time Friend</title><link>https://time-friend.com/en/tags/angular/</link><description>Recent content in Angular on Time Friend</description><generator>Hugo</generator><language>en-GB</language><lastBuildDate>Wed, 29 Jul 2026 15:15:07 +0800</lastBuildDate><atom:link href="https://time-friend.com/en/tags/angular/index.xml" rel="self" type="application/rss+xml"/><item><title>Angular Path Alias Configuration</title><link>https://time-friend.com/en/archive/angular-path-alias-configuration/</link><pubDate>Thu, 27 Dec 2018 22:17:36 +0000</pubDate><guid>https://time-friend.com/en/archive/angular-path-alias-configuration/</guid><description>&lt;p&gt;Angular CLI has webpack built-in, so path aliases can be configured.
The configuration method is almost the same.&lt;/p&gt;
&lt;h1 id="configure-path-alias"&gt;Configure Path Alias&lt;/h1&gt;
&lt;p&gt;Find the &lt;code&gt;tsconfig.json&lt;/code&gt; file in your project root directory.&lt;/p&gt;
&lt;p&gt;Note: If your configuration doesn&amp;rsquo;t take effect, check if your &lt;code&gt;baseUrl&lt;/code&gt; is configured correctly.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-json" data-lang="json"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;compilerOptions&amp;#34;&lt;/span&gt;: {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;baseUrl&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;./src/&amp;#34;&lt;/span&gt;, 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;paths&amp;#34;&lt;/span&gt;: {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;@app/*&amp;#34;&lt;/span&gt;: [&lt;span style="color:#e6db74"&gt;&amp;#34;app/*&amp;#34;&lt;/span&gt;],
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;@services/*&amp;#34;&lt;/span&gt;: [&lt;span style="color:#e6db74"&gt;&amp;#34;app/services/*&amp;#34;&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="before-configuration"&gt;Before Configuration&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;import&lt;/span&gt; { &lt;span style="color:#a6e22e"&gt;Api&lt;/span&gt; } &lt;span style="color:#a6e22e"&gt;from&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;../../../../../services/api.service&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;import&lt;/span&gt; { &lt;span style="color:#a6e22e"&gt;xxx&lt;/span&gt; } &lt;span style="color:#a6e22e"&gt;from&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;../../../../../services/api.xxx&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="after-configuration"&gt;After Configuration&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;import&lt;/span&gt; { &lt;span style="color:#a6e22e"&gt;Api&lt;/span&gt; } &lt;span style="color:#a6e22e"&gt;from&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;@services/api.service&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;import&lt;/span&gt; { &lt;span style="color:#a6e22e"&gt;xxx&lt;/span&gt; } &lt;span style="color:#a6e22e"&gt;from&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;@services/api.xxx&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Some development tips, hope this helps you.&lt;/p&gt;</description></item><item><title>Recommended: An Angular Electron Project Template Ready to Use</title><link>https://time-friend.com/en/archive/angular-electron-template/</link><pubDate>Thu, 20 Dec 2018 19:02:36 +0000</pubDate><guid>https://time-friend.com/en/archive/angular-electron-template/</guid><description>&lt;p&gt;The official Angular website does provide an official Angular template for Electron.
But the version is 2.0, which is really too old. I doubt anyone will maintain it anymore.
Yet it&amp;rsquo;s still listed on the official site.
This misleads many beginners — at least it made me think there wasn&amp;rsquo;t a newer, usable Electron template for quickly creating projects.&lt;/p&gt;
&lt;h1 id="angular-electron"&gt;Angular-electron&lt;/h1&gt;
&lt;p&gt;Here I recommend a highly complete template that&amp;rsquo;s ready to use out of the box:&lt;/p&gt;</description></item><item><title>Angular 7 + Electron Main Process and Renderer Process Communication</title><link>https://time-friend.com/en/archive/angular-electron-ipc/</link><pubDate>Wed, 19 Dec 2018 19:02:36 +0000</pubDate><guid>https://time-friend.com/en/archive/angular-electron-ipc/</guid><description>&lt;h1 id="process-types-in-electron"&gt;Process Types in Electron&lt;/h1&gt;
&lt;p&gt;In Electron, there are two types of processes: the &lt;code&gt;main process&lt;/code&gt; and the &lt;code&gt;renderer process&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;renderer process&lt;/code&gt; can be understood as the view layer — the process that displays pages, which we&amp;rsquo;re very familiar with.
Here you can use Node.js API capabilities as well as perform browser operations we&amp;rsquo;re already used to.
But when you need to invoke operations that only the main process can handle, you need a communication mechanism to tell the main process what you want to do.&lt;/p&gt;</description></item><item><title>Building an Angular 7 + Electron Desktop App from Scratch</title><link>https://time-friend.com/en/archive/angular7-electron-setup/</link><pubDate>Tue, 18 Dec 2018 19:02:36 +0000</pubDate><guid>https://time-friend.com/en/archive/angular7-electron-setup/</guid><description>&lt;h1 id="what-is-electron"&gt;What is Electron?&lt;/h1&gt;
&lt;p&gt;Electron is a library for building desktop applications with JavaScript, HTML, and CSS. These applications can be packaged to run on Mac, Windows, and Linux, and can also be published to the Mac and Windows App Stores.
This means that as long as you have front-end development skills, you can easily build cross-platform desktop applications.&lt;/p&gt;
&lt;h2 id="electrons-main-process-and-renderer-process"&gt;Electron&amp;rsquo;s Main Process and Renderer Process&lt;/h2&gt;
&lt;p&gt;Electron has two types of processes: the main process and the renderer process. Some modules can only run on one or the other, while others have no restrictions. The main process acts more as a behind-the-scenes role, while renderer processes are the individual windows of the application.&lt;/p&gt;</description></item><item><title>Angular Template Safe Navigation Operator ( ?. )</title><link>https://time-friend.com/en/archive/angular-safe-navigation-operator/</link><pubDate>Sun, 25 Nov 2018 22:17:36 +0000</pubDate><guid>https://time-friend.com/en/archive/angular-safe-navigation-operator/</guid><description>&lt;p&gt;This is very practical and frequently used operator in Angular development.
React and Vue don&amp;rsquo;t have this feature natively.&lt;/p&gt;
&lt;h1 id="safe-navigation-operator---"&gt;Safe Navigation Operator ( ?. )&lt;/h1&gt;
&lt;p&gt;In our daily development, when accessing property paths.&lt;/p&gt;
&lt;p&gt;If for some reason the path contains &lt;code&gt;null&lt;/code&gt; or &lt;code&gt;undefined&lt;/code&gt;, and we continue to access properties, the entire program will crash, preventing the program from continuing to run.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s an example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;var&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;obj&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;a&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;b&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt;{ &lt;span style="color:#75715e"&gt;// Sometimes, this property might not exist
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;c&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;d&lt;/span&gt;&lt;span style="color:#f92672"&gt;:&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; 
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;obj&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;a&lt;/span&gt; &lt;span style="color:#75715e"&gt;// Normal access
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;obj&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;b&lt;/span&gt; &lt;span style="color:#75715e"&gt;// If this property sometimes doesn&amp;#39;t exist, accessing it will only return undefined, won&amp;#39;t cause an error
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;obj&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;b&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;c&lt;/span&gt; &lt;span style="color:#75715e"&gt;// When property b doesn&amp;#39;t exist, accessing properties on undefined will definitely cause the program to crash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Safe navigation solves the above problem. We just need to change the &lt;code&gt;.&lt;/code&gt; before uncertain properties to &lt;code&gt;?.&lt;/code&gt; to avoid errors. When no value is found, it will default to empty.&lt;/p&gt;</description></item></channel></rss>