<?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 Honorary Marleyans on Medium]]></title>
        <description><![CDATA[Stories by Honorary Marleyans on Medium]]></description>
        <link>https://medium.com/@HonoraryMarleyans?source=rss-4b8774ec33b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ATEO3GbIqxVZV-kqTRzitQ@2x.jpeg</url>
            <title>Stories by Honorary Marleyans on Medium</title>
            <link>https://medium.com/@HonoraryMarleyans?source=rss-4b8774ec33b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 05:22:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@HonoraryMarleyans/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[dotnet summary]]></title>
            <link>https://medium.com/@HonoraryMarleyans/dotnet-summary-cf470f3f4058?source=rss-4b8774ec33b------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf470f3f4058</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Honorary Marleyans]]></dc:creator>
            <pubDate>Tue, 05 Nov 2024 06:04:54 GMT</pubDate>
            <atom:updated>2024-11-05T06:04:54.357Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. .NET SDK (Start of Development)</h3><ul><li><strong>Purpose</strong>: The .NET SDK is the first tool you’ll need because it provides the essentials for development, including the <strong>compiler</strong>, <strong>.NET CLI</strong>, and <strong>project templates</strong>.</li><li><strong>Usage</strong>:</li><li><strong>Install</strong> the .NET SDK on your development environment.</li><li><strong>Create a project</strong> using CLI commands (e.g., dotnet new console for a console app).</li><li><strong>Write code</strong> within the structure provided by the template.</li><li><strong>Compile and test</strong> using SDK tools (dotnet build, dotnet run, dotnet test).</li></ul><p>The SDK allows you to write, compile, and test code on your local machine and provides templates and tools to structure your project effectively.</p><h3>2. .NET Base Libraries (During Development)</h3><ul><li><strong>Purpose</strong>: As you develop your application, you’ll use the .NET Base Libraries to simplify tasks like file handling, network operations, and more.</li><li><strong>Usage</strong>:</li><li><strong>Import and use libraries</strong> (like System.Collections.Generic, System.Net.Http) to interact with standard functions such as data manipulation, networking, file I/O, or date-time management.</li><li><strong>Avoid reinventing the wheel</strong> by leveraging built-in classes and methods for common tasks.</li></ul><p>These libraries allow you to focus on the core logic of your application rather than building low-level functionalities from scratch.</p><h3>3. .NET Assemblies (Compilation and Intermediate Output)</h3><ul><li><strong>Purpose</strong>: Assemblies are the output of your code after compilation and form the building blocks of your application.</li><li><strong>Usage</strong>:</li><li><strong>Build the project</strong> using dotnet build. This process generates <strong>assemblies</strong> (e.g., .dll files for libraries and .exe for executable applications).</li><li>Assemblies contain <strong>metadata</strong> and <strong>Intermediate Language (IL)</strong> code, which can be shared and referenced by other .NET applications if your project is structured in multiple assemblies.</li><li>For modular development, organize your code into separate projects, each compiled into its own assembly, allowing easy reuse and management.</li></ul><p>Assemblies are your deployable and shareable units of code and are referenced by the runtime at execution.</p><h3>4. .NET Runtime (Execution and Deployment)</h3><ul><li><strong>Purpose</strong>: The .NET Runtime is used to <strong>execute</strong> your application, providing services like memory management and Just-in-Time (JIT) compilation of IL code into native machine code.</li><li><strong>Usage</strong>:</li><li>In development, <strong>run the application</strong> locally using dotnet run, which invokes the runtime to execute your compiled assemblies.</li><li>For deployment, you may install the appropriate runtime on the server or publish your application as a <strong>self-contained deployment</strong> (including the runtime) if needed.</li><li>The runtime is required whenever the application is executed, either during testing, debugging, or after deployment.</li></ul><p>The runtime provides the final layer, enabling the compiled assemblies to execute on different environments, making your application functional on end-user machines.</p><h3>Summary Workflow:</h3><ol><li><strong>Install the .NET SDK</strong> to set up your development environment and create your project.</li><li><strong>Develop your application</strong> by writing code and leveraging <strong>.NET Base Libraries</strong> for essential functionalities.</li><li><strong>Compile code into assemblies</strong> using SDK tools, creating executable units (EXE/DLL files).</li><li><strong>Run your application</strong> using the .NET Runtime, either on your local machine, in testing environments, or in production.</li></ol><p>In this way, each .NET component is used at specific stages, from setting up the environment and writing code to building and executing the final application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf470f3f4058" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[大會計師教你從財報數字看懂產業本質-心得]]></title>
            <link>https://medium.com/@HonoraryMarleyans/%E5%A4%A7%E6%9C%83%E8%A8%88%E5%B8%AB%E6%95%99%E4%BD%A0%E5%BE%9E%E8%B2%A1%E5%A0%B1%E6%95%B8%E5%AD%97%E7%9C%8B%E6%87%82%E7%94%A2%E6%A5%AD%E6%9C%AC%E8%B3%AA-%E5%BF%83%E5%BE%97-326f460cb26c?source=rss-4b8774ec33b------2</link>
            <guid isPermaLink="false">https://medium.com/p/326f460cb26c</guid>
            <category><![CDATA[財務報表]]></category>
            <category><![CDATA[讀書心得]]></category>
            <category><![CDATA[股票]]></category>
            <category><![CDATA[心得]]></category>
            <category><![CDATA[會計]]></category>
            <dc:creator><![CDATA[Honorary Marleyans]]></dc:creator>
            <pubDate>Tue, 29 Nov 2022 02:39:06 GMT</pubDate>
            <atom:updated>2022-11-29T02:39:06.121Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>財報的意義不是只有帳面數字有賺錢就好，透過閱讀這本書，解讀財報數字就算不用加減乘除，一樣能從: 資產負債表-評估企業的真實身價、損益表-判斷公司在產業內的競爭力、現金流量表-檢視真賺錢或只是數字好看</blockquote><p>財報數字就是反應企業經營的狀況，有很多的股票分析網站，都將這些財報數字透過圖表讓數據可視化，而且不只是能夠反應財報呈現的現況，甚至是歷史數據，以及未來的預測，都可以成為可視化的圖表；但即使如此，有時候看到財報或者圖表呈現的數據，如果不是很有經驗，根本不知道呈現的數據，對該企業來說到底是賺多還是賺少。</p><p>也因為這樣的原因，本書作者張明輝先生，曾任資誠聯合會計師事務所所長，將他在會計生涯中所學經驗分享出來，讓讀者在看完這本書之後，在讀到企業的資產負債表、損益表以及現金流量表時，不至於霧裡看花，甚至也提供了關於企業作假帳可能出現的財報情況。</p><p>書中在資產負債表、損益表以及現金流量表的各種數據呈現，透過很多範例說明，有些是和企業自己的往年數據比較，有些是把同業的企業當作對比，更有趣的事情是，當透過不同產業間的數據分析比較，也可以看出每種產業的特性，呈現出不一樣的財報狀況。</p><p><strong>以資產負債表中</strong>兼看<em>合</em><strong><em>併報表和個體報表的差異為例</em></strong>，顯示器大廠華映的報表中，合併了在中國的華映科技的財報，由於在中國的華映多半時候是獲利的，而在台灣的華映多半時候是虧損的，而事實上，在台灣的華映只持有中國華映的25%股權而已。因此在合併完在中國的華映財務報表後，呈現給投資人看的合併報表，會讓人以為華映這間公司的經營狀況還算可以接受。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Zab7oO44QFu-U_7TPUTzQ.png" /><figcaption>2017年第四季，華映資產負債表(來源: <a href="https://www.cnyes.com/pre/bs/2475.html">鉅亨</a>)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WNHoHpNG5U9327tO_Aa9jw.png" /><figcaption>2017年第四季，華映資產負債表(來源: <a href="https://www.cnyes.com/pre/bs/2475.html">鉅亨</a>)</figcaption></figure><p>但事實上，權益總計佔總資產的42%，但是歸屬於母公司之業主權益僅佔總資產的10%，換句話說，大部分的權益都是在中國的華映小股東擁有，因此在這種情況下，看合併報表是沒有意義的。</p><p>另外，<strong>在損益表上</strong>，書中也提到很多方式可以評估企業在產業內的競爭力，其中最讓人印象深刻的部分，<strong><em>透過推銷費用的合理性反應產品的市場力</em></strong>。由於推銷費用是一家公司為了推銷商品或勞務的過程，所花的各項費用，當一項產品必須要靠大量的促銷活動，才能夠有不錯的銷售成績，也就是推銷費用的成長率高於營業收入的成長率，這樣這項產品的產品力就略顯不足。以台積電為例，由於產品力與商譽，台積電在推銷費用上，只佔營收的0.6%。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qEB0bH8RZ4IOQAZx3c1cOg.png" /><figcaption>2330 台積電，損益表中的推銷費用，只佔營收的0.6%。(來源: <a href="https://www.cnyes.com/pre/bs/2475.html">鉅亨</a>)</figcaption></figure><p>從產業別也可以看出推銷費用的差異，以販售精品的企業來說，由於精品的定位與銷售型態，推銷費用反而變成需要提高費用的項目，以販售西服的嘉裕為例，</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o86Djmz3NFeZ-6biynYQSQ.png" /><figcaption>1417 嘉裕，損益表中的推銷費用，佔營收的28.63%。(來源: <a href="https://www.cnyes.com/pre/bs/2475.html">鉅亨</a>)</figcaption></figure><p>最後在<strong>現金流量表</strong>的部分，最讓人印象深刻的是，<strong><em>投資人如何從現金流量表中解讀企業到底賺得多少現金，獲利模式穩不穩定，品質好不好。</em></strong></p><p>其中提到一個分析的比例關係，將[稅前淨利(淨損)+折舊及攤銷費用-支付的所得稅]和[營業活動之現金流入(流出)數]相比較，如果可以得到很穩定的比例關係，則表示此企業的獲利品質穩定。</p><p>書中提到的分析方式還有很多，而且都有很多範例可以參考；在還沒有讀過這本書之前，以沒有會計概念或者是對股票研究不深的人來說，看到財務報表、損益表和現金流量表所呈現的數據，也只覺得這些金額好大，或者是單純從數值的正負，來判斷賺錢或虧損，完全沒有辦法推測數字背後代表的故事。<strong>但是看完這本書之後，就會發現這些數字，不只是數字，是企業，甚至是整個產業的樣貌。</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=326f460cb26c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular material table sticky failed]]></title>
            <link>https://medium.com/@HonoraryMarleyans/angular-material-table-sticky-failed-f469e1cea9f9?source=rss-4b8774ec33b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f469e1cea9f9</guid>
            <category><![CDATA[table]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular-material]]></category>
            <category><![CDATA[issues]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Honorary Marleyans]]></dc:creator>
            <pubDate>Wed, 26 Oct 2022 08:24:49 GMT</pubDate>
            <atom:updated>2022-10-26T08:24:49.122Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article would show you how to deal with sticky failed while dynamically adding data to source table.</h4><p><strong>What are sticky columns?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*MSKLiLBGQfobb4xl3O7T5A.png" /><figcaption>Sticky columns example from <a href="https://material.angular.io/components/table/examples">Angular material official webpage</a></figcaption></figure><p>Sticky columns enable you to display specific columns at all times while the user scrolls the Grid horizontally.</p><p>Angular material provides sticky property that we can use directly in .html file.</p><p>Here is the example from Angular material official webpage.</p><p><a href="https://stackblitz.com/run?file=src%2Fapp%2Ftable-sticky-columns-example.html">Sticky columns example</a>.</p><p>As it shows , we just use the sticky and the stickyEnd properties in &lt;ng-container&gt; element.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4a0c11d7f44b5dcb83b717a57c94331b/href">https://medium.com/media/4a0c11d7f44b5dcb83b717a57c94331b/href</a></iframe><ul><li>line 5, we set sticky property</li><li>line 14, we set stickyEnd property</li></ul><p>The columns would roll between Name Column and Symbol Column. Only Name Column and Symbol Column would stick on the screen.</p><h4>How to fix sticky failed problem when we add data dynamically?</h4><p>Once the source table dynamically like the following code, the sticky column would fail.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ab20f275c183bf17bf6d801f7cb34ed/href">https://medium.com/media/7ab20f275c183bf17bf6d801f7cb34ed/href</a></iframe><p>It fails because the Angular didn’t check the view again. We did the by adding the following codes.</p><pre>@ViewChild(MatTable) table: MatTable&lt;any&gt;;</pre><p>Implement AfterViewChecked and add the following codes.</p><pre>ngAfterViewChecked(): void {<br>    if (this.table) {<br>        this.table.updateStickyColumnStyles();<br>    }<br>}</pre><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/efd162403fe9f78df53e26ece27a0dca/href">https://medium.com/media/efd162403fe9f78df53e26ece27a0dca/href</a></iframe><p>So the steps to solve sticky columns fail problem are,</p><ol><li>Add @ ViewChild to get table element.</li><li>Implement AfterViewedChecked method</li><li>Update table by using updateStickyColumnStyles()in AfterViewedChecked method.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f469e1cea9f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS shorten name- module 1 : compute in the cloud]]></title>
            <link>https://medium.com/@HonoraryMarleyans/aws-shorten-name-module-1-compute-in-the-cloud-7093f9ade3f5?source=rss-4b8774ec33b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7093f9ade3f5</guid>
            <category><![CDATA[skills-development]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[notes]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <dc:creator><![CDATA[Honorary Marleyans]]></dc:creator>
            <pubDate>Tue, 11 Oct 2022 03:10:23 GMT</pubDate>
            <atom:updated>2022-10-11T03:10:23.123Z</atom:updated>
            <content:encoded><![CDATA[<h3>AWS shorten name- module 1 : compute in the cloud</h3><p>Amazon Elastic compute cloud<br> EC2</p><p>high-frequency online transaction processing <br> OLTP</p><p>input/output operations per second<br> IOPS</p><p>Elastic Load Balancing<br> ELB</p><p>Amazon Simple Queue Service<br> SQS</p><p>Amazon Simple Notification Service<br> SNS</p><p>Amazon Elastic Container Service<br> Amazon ECS</p><p>Amazon Elastic Kubernetes Service<br> Amazon EKS</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7093f9ade3f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[4 Tips about Angular Pipe]]></title>
            <link>https://medium.com/@HonoraryMarleyans/4-tips-about-angular-pipe-26682216fbda?source=rss-4b8774ec33b------2</link>
            <guid isPermaLink="false">https://medium.com/p/26682216fbda</guid>
            <category><![CDATA[tips]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[pipes]]></category>
            <category><![CDATA[asynchronous]]></category>
            <dc:creator><![CDATA[Honorary Marleyans]]></dc:creator>
            <pubDate>Tue, 04 Oct 2022 03:06:03 GMT</pubDate>
            <atom:updated>2022-10-04T03:06:03.643Z</atom:updated>
            <content:encoded><![CDATA[<ul><li>Pipe order</li><li>Using multiple parameter</li><li>What is pure pipe</li><li>Async pipe</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dz99Woyskorob_vFHTE0-Q.png" /><figcaption>Data and pipe</figcaption></figure><h3><strong>Pipe order</strong></h3><p>When we use pipe in html file, browsers would compile the code from left to right. So it is important to use pipe in order.</p><p>Take the date pipe and the uppercase pipe for example, we set a variable named dateParameter in .ts file and give it a date type.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e745b7e18e2ace2e52af2a5544468f2c/href">https://medium.com/media/e745b7e18e2ace2e52af2a5544468f2c/href</a></iframe><p>We use string binding in .html file to get the dateParameter variable. And we also use uppercase and data pipe with parameter &#39;fullDate&#39;.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3580539078ca6c76dcf4f4137707bc53/href">https://medium.com/media/3580539078ca6c76dcf4f4137707bc53/href</a></iframe><p>And we can get the result is like the following picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*0_ICFT-Gj5PR7RkoS-f7Ng.png" /><figcaption>Date and uppercase pipe result</figcaption></figure><p>But now if we change the order of date and uppercase pipe, the browser would go wrong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*-X31S_500n6b7bHHbAaGUw.png" /><figcaption>Error message</figcaption></figure><h3>Using multiple pipe parameters</h3><p>We can show the usage of multiple pipe parameters in default pipes and self defined pipes.</p><h4>Default pipes</h4><p>We take above example the date variable to show.</p><p>According to the angular official webpage, we can add the time zone setting to the date pipe by connected the parameter with colon.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6924e3c1533da5a45350f2b772f97642/href">https://medium.com/media/6924e3c1533da5a45350f2b772f97642/href</a></iframe><p>Originally we define the date with 2022/01/01, then we set the date with time zone +0430 that makes the result change to 2021/12/31.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/202/1*0Cqkq8RIU66XivH1Hth6wQ.png" /><figcaption>After using time zone setting</figcaption></figure><h4>Self Defined pipe</h4><p>If we use self defined pipe, we can build a pipe method and add multiple parameters depend on the calculation.</p><p>Use Angular cli to generate a pipe service</p><p>ng g pipe filename</p><p>And the pipe service would be similar to the following code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2115e8d62b0fb380449a2bb7220e5a25/href">https://medium.com/media/2115e8d62b0fb380449a2bb7220e5a25/href</a></iframe><p>So in .html file, we just use colon to connect the parameters.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e81fd67d620970b021129f735fcd9bd/href">https://medium.com/media/5e81fd67d620970b021129f735fcd9bd/href</a></iframe><p><strong>We have to notice that the pipeName used in .html file is the name which is defined in pipe decorator(@pipe) in pipe service.</strong></p><h3>What is pure pipe</h3><p>As the statement in Angular official webpage, the pure pipe state is the initial setup.</p><p><em>By default, </em><a href="https://angular.io/guide/pipes#detecting-pure-changes-to-primitives-and-object-references"><em>pipes are defined as pure</em></a><em> so that Angular executes the pipe only when it detects a pure change to the input value. A pure change is either a change to a primitive input value (such as </em><em>String, </em><em>Number, </em><em>Boolean, or </em><em>Symbol), or a changed object reference (such as </em><em>Date, </em><em>Array, </em><em>Function, or </em><em>Object).</em></p><p>The pipe interface file states that</p><p><em>Set ‘pure’ to false. In this case, the pipe is invoked on each change-detection cycle, even if the arguments have not changed.</em></p><p>Here is an example that shows a pure pipe with an array as input might not work the way you want.</p><p>First of all, we built a pipe service with pure state true(initial setting). The method in this pipe service would make the array element to uppercase. For demonstration purpose, I just chose a simple one to show. Actually the uppercase was built in Angular pipes already.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/672c51d99290b85f976cefe3e83a0856/href">https://medium.com/media/672c51d99290b85f976cefe3e83a0856/href</a></iframe><p>Then we set up a string array and an added-method in .ts file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b949ce8d5e35484983a573f0e9602085/href">https://medium.com/media/b949ce8d5e35484983a573f0e9602085/href</a></iframe><p>Finally we built the code in .html file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ff3384880d6ddaf65715435eb889014e/href">https://medium.com/media/ff3384880d6ddaf65715435eb889014e/href</a></iframe><p>Then we would find out that the watermelon item didn’t show even if we had clicked the add button. But if we remove the self defined pipe, it would work without pipe results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*DJ4EnRUta1CUBTQHEHecOw.png" /><figcaption>Results without self defined pipe</figcaption></figure><p>The situation is that to avoid side affect, a pure function should always return the same output by given the same input.</p><p>Once we change the pipe service default pure state to false, the fruits list would grow by clicking add button and the string items would become uppercase.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d16e9c72bd145e52ca7a411aa2ac216/href">https://medium.com/media/6d16e9c72bd145e52ca7a411aa2ac216/href</a></iframe><p>The result is as the following picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*U_OLSsnZ8v9U6FOXM1Gtvw.png" /><figcaption>Result with pure state to false</figcaption></figure><h3>Async pipe</h3><p>If we just show an asynchronous object in .html file with string interpolation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d79848c4606d6fba1f668861f5f9a3c6/href">https://medium.com/media/d79848c4606d6fba1f668861f5f9a3c6/href</a></iframe><p>We would get a object type view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*R4UW5NeVOUJBBcf1biUbnA.png" /><figcaption>Asynchronous object picture without async pipe</figcaption></figure><p>And if we set a async pipe to this object, we would get the exact answer finally.</p><p>&lt;h2&gt;Fruits status:{{appStatus | async}}&lt;/h2&gt;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/276/1*Blw_5SWiSmnDAvdexBFrKA.png" /><figcaption>Asynchronous object picture with async pipe</figcaption></figure><p>And here is the .ts setting about showing fruits status.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/514d8143fe15ba708ee23e2fbdc40de4/href">https://medium.com/media/514d8143fe15ba708ee23e2fbdc40de4/href</a></iframe><p>Summarized</p><ul><li>Pipe would be compiled from left to right.</li><li>Using colon to connect multiple parameters.</li><li>Pure state is true or false would affect the display way of view.</li><li>Using async pipe to help asynchronous object show correctly.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26682216fbda" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rewrite JavaScript autocomplete example in Angular]]></title>
            <link>https://medium.com/@HonoraryMarleyans/rewrite-javascript-autocomplete-example-in-angular-7151c34809d7?source=rss-4b8774ec33b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7151c34809d7</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[autocomplete]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Honorary Marleyans]]></dc:creator>
            <pubDate>Mon, 26 Sep 2022 02:50:25 GMT</pubDate>
            <atom:updated>2022-09-26T02:50:25.666Z</atom:updated>
            <content:encoded><![CDATA[<p>What we are going to do is to change the autocomplete example in w3school into Angular.</p><p>Here is the<a href="https://www.w3schools.com/howto/howto_js_autocomplete.asp"> example code</a>.</p><p>Cause we rewrite with Angular, there are some components we have to build.</p><p>a. .html part =&gt; Use some properties or events provided by Angular to set up the whole template.</p><p>b. .ts part =&gt; Move the logic code which is originally write in .html part into .ts file, so the structure of the project would be more simple.</p><p>c. .css part=&gt; Only add a selector to decide whether the autocomplete suggestion lists show or not.</p><p>d. .service part=&gt; To get the asynchronous data with the httpClient module provide by Angular, we build the code in a service component.</p><h3>.html part</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/711f0d105ba2cccc4561ac783a063297/href">https://medium.com/media/711f0d105ba2cccc4561ac783a063297/href</a></iframe><p>&gt;line 7: Add a property binding element[formControl] and name it in .ts file, so we can use the reactive form provided by Angular.</p><p>&gt;line 7: Add a keydown event binding to input element. While users press up, down, and enter, the style of the suggestion lists would be changed by an index. The index will increase or decrease with the user press up or down .</p><p>&gt;line 10: Use a variable which’s type is boolean to decide the suggestion list shows or not.</p><p>&gt;line 13: Use *ngFor to show the suggestion list items and slice to restrict the amount of suggestion list items.</p><p>&gt;line 14: Use event binding to detect the mouse click event, and also use the input reference to bring the value clicked by users into .ts file.</p><p>&gt;line 16: Make the value of the input equal to the binding value, and add a reference to let event binding use the input value.</p><h3>.ts part</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca41059beef35e610270d2416241e72e/href">https://medium.com/media/ca41059beef35e610270d2416241e72e/href</a></iframe><p>&gt;line 20: Use http client in service to get the asynchronous data and set a variable to keep the value. Actually before we subscribe to the variable, the function would not work.</p><p>&gt;line 23: When the input value changes, the rxjs operators would trigger sequentially. If the operations are not related to the input data, we would use tap operator to deal with the function.</p><p>&gt;line 27: Use startWith() to emit a empty given value first.</p><p>&gt;line 28: Use debounceTime() to avoid frequently query data from backend.</p><p>&gt;line 29: Use distinctUntilChanged() to emit data when the current value is different than the last.</p><p>&gt;line 30: Use switchMap() to unsubscribe last input content, and only use the latest input content to query data.</p><p>&gt;line 52: When users use mouse to click the suggestion item, the function would be triggered and sets the suggestion value into input formcontrol.</p><p>&gt;line 57: When users use keyboard to select the suggestion items, the style would change according to the index value. And when users press the enter key, the suggestion value would be set into input formcontrol.</p><h3>service part</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7abe2c52414e8d77b677893eaa40d02/href">https://medium.com/media/f7abe2c52414e8d77b677893eaa40d02/href</a></iframe><p>&gt;line 11: Use http client to query data by the url.</p><p>&gt;line 18: When users key in the search content, the function will be triggered to get the data. The function would check the search content fits the background data or not.</p><h3>json file</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8da1ec9b14175d68641bce75fffbab98/href">https://medium.com/media/8da1ec9b14175d68641bce75fffbab98/href</a></iframe><p>The json file keeps the country data which you can get from<a href="https://www.w3schools.com/howto/howto_js_autocomplete.asp"> w3school website</a>.</p><h3>interface file</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/18ec9f8fa49448a40b6756ec2b0b1c89/href">https://medium.com/media/18ec9f8fa49448a40b6756ec2b0b1c89/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c17970c70ce2ba2d148d024e31ce26f6/href">https://medium.com/media/c17970c70ce2ba2d148d024e31ce26f6/href</a></iframe><p>The two interface files provide key pair types that we can deal with the data easier.</p><p>Conclusion:</p><ul><li>If we want to rewrite the autocomplete example in w3school with Angular, we have to change the way how the html view be generated. We have to use *ngIf or *ngFor to generate html view.</li><li>According to the structure of Angular, we have to sperate the code in .ts, .service and .html file by its purpose.</li><li>It is easier to maintain with strong typed structure.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7151c34809d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[使用Angular 改寫 JavaScript autocomplete example]]></title>
            <link>https://medium.com/@HonoraryMarleyans/%E4%BD%BF%E7%94%A8angular-%E6%94%B9%E5%AF%AB-javascript-autocomplete-example-6b6977b54bd3?source=rss-4b8774ec33b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b6977b54bd3</guid>
            <category><![CDATA[autocomplete]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Honorary Marleyans]]></dc:creator>
            <pubDate>Tue, 06 Sep 2022 08:34:03 GMT</pubDate>
            <atom:updated>2022-09-06T08:34:03.685Z</atom:updated>
            <content:encoded><![CDATA[<p>從w3schools，看到<a href="https://www.w3schools.com/howto/howto_js_autocomplete.asp">autocomplete</a>的範例，參考w3schools的範例進行改寫，使用Rxjs實作autocomplete功能。</p><figure><img alt="autocomplete" src="https://cdn-images-1.medium.com/max/446/1*bVLx7bZtS40fnC7u7WnVqA.png" /><figcaption>w3school Java Script autocomplete example</figcaption></figure><p>首先是關於html畫面呈現，如果使用Angular配置和原本範例相比，我們必須要更改以下項目:</p><p>a. 在範例中，使用JavaScript動態生成的autocomplete清單，要直接寫在html上，並透過Angular提供的屬性來達到控制是否顯示。</p><p>b. 使用&lt;strong&gt;強調符合搜尋字詞，也需要另外透過TypeScript設定好變數內容，再透過插值綁定顯示。</p><p>c. 在搜尋欄位&lt;input&gt;中，每次輸入值之後，透過reactive form提供的valueChanges來達到非同步判斷輸入的內容。</p><p>接著是css style的設定，原本使用JavaScript操作的html內容，修改之後變成直接在html上顯示並且操作，css的設定基本上和原始範例一樣。</p><p>最後是在TypeScript處理的事件，例如:選取建議清單內的項目後，自動patchValue到input form中，或者是其他要透過插值綁定顯示的變數設定，最後還有RxJs的設定。</p><h3><strong>首先是html頁面的改寫，將它改成以下內容</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/711f0d105ba2cccc4561ac783a063297/href">https://medium.com/media/711f0d105ba2cccc4561ac783a063297/href</a></iframe><p>.html中的程式碼描述如下:</p><p>&gt;第7行的input加入[formConrtol]使用ReactiveForm，讓input變成formControl，方便在.ts檔案中，使用valueChange偵測非同步變化。</p><p>&gt;第7行的input加入(keydown)的事件繫結，設定當按下鍵盤上的，上下以及enter鍵時，透過設定一個index增減變化，來改變建議清單的style，以及選擇到要輸入的清單項目。</p><p>&gt;第10行的div用[ngClass]來判斷是否顯示建議清單，當透過滑鼠或鍵盤選擇要搜尋的建議清單中的項目後，就不再顯示建議清單，除非重新輸入搜尋內容。</p><p>&gt;第13行的*ngFor用來顯示儲存在ts中的建議清單列表。</p><p>&gt;第14行的onAutocomplete(inputSuggestion)，當滑鼠點擊建議項目後，觸發此方法，並自動將此input的值，填入搜尋欄。</p><p>&gt;第14行的[ngClass]，當activeIndex根據鍵盤上下增減，如果等於目前的項目，則改變顏色。</p><p>&gt;第14行的&lt;strong&gt;，根據在.ts中判斷要強化的關鍵字，再透過文字繫結顯示在.html中</p><p>&gt;第15行的&lt;input&gt;，要讓Angular可以讀取到我們使用滑鼠點取的項目，因此設定#inputSuggestion reference，再將此reference&lt;HTMLInputElement&gt;放入14行的click事件中，來傳遞選取的項目值。</p><h3>關於CSS的內容</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/29c022a3e7e8c37cb816aacee69c00fe/href">https://medium.com/media/29c022a3e7e8c37cb816aacee69c00fe/href</a></iframe><p>在CSS設定中，基本上使用範例中的設定，只增加了要不要顯示建議清單的class=&gt; listOff的判斷。</p><h3>取得資料的service內容</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f7abe2c52414e8d77b677893eaa40d02/href">https://medium.com/media/f7abe2c52414e8d77b677893eaa40d02/href</a></iframe><p>service的描述如下</p><p>&gt;第3行的變數是儲存country array的地方</p><p>&gt;第5行的變數是儲存取得來自httpClient回傳的observable物件</p><p>&gt;第11行的方法是設定httpClient方法，並回傳特定的資料</p><p>&gt;第19行是當搜尋欄input的值有變化時，判斷從httpClient回傳的資料，是否有包含使用者輸入的搜尋內容，並回傳。</p><h3><strong>在service中，建立的country array json結構如下</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8da1ec9b14175d68641bce75fffbab98/href">https://medium.com/media/8da1ec9b14175d68641bce75fffbab98/href</a></iframe><p>&gt;建立json檔案，加上key pair value，有助於我們在ts結構中，建立interface，方便存取資料。</p><h3>在整個架構中，都會用到interface結構如下</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/18ec9f8fa49448a40b6756ec2b0b1c89/href">https://medium.com/media/18ec9f8fa49448a40b6756ec2b0b1c89/href</a></iframe><p>&gt;這是存取原始資料的介面</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c17970c70ce2ba2d148d024e31ce26f6/href">https://medium.com/media/c17970c70ce2ba2d148d024e31ce26f6/href</a></iframe><p>&gt;這介面是用來顯示在html中，將符合搜尋關鍵字的項目，分別使用&lt;strong&gt;和&lt;p&gt;的方式標示出來。</p><h3>而.ts邏輯的內容</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ca41059beef35e610270d2416241e72e/href">https://medium.com/media/ca41059beef35e610270d2416241e72e/href</a></iframe><p>&gt;第5行變數，用來聯繫html搜尋內容的input元件，reactive form控制元件。</p><p>&gt;第7行變數，在html中，判斷是否顯示建議清單，當選擇建議項目後，會變成false(不顯示)，當使用者重新輸入後，則變更狀態為true(重新顯示)</p><p>&gt;第9行變數，儲存從service取得的資料。</p><p>&gt;第11行變數，讓鍵盤上下指令可以控制html上的style狀態。</p><p>&gt;第13行變數，用來限制最多顯示的建議項目筆數。</p><p>&gt;在第19行ngOnInit中，透過reactive form control提供的非同步方法valueChanges()，當input值有變化時，進行一系列RxJS操作。</p><p>=&gt;使用tap處理和資料流沒有相關的邏輯，例如:</p><p>a. html建議項目的顯示狀態</p><p>b. html建議項目的顯示筆數</p><p>c. 使用者輸入資料的長度</p><p>=&gt;使用startWith(&#39; &#39;)，給予一個初始事件值。</p><p>=&gt;使用debounceTime(500)，等待0.5秒，這段時間等使用者不再輸入，再進行下一個操作。</p><p>=&gt;使用 distinctUntilChanged()，只送出和最後一筆相比有差異的資料出去。</p><p>=&gt;使用switchMap()，會當有新的訂閱進來的時候，會取消訂閱上一筆資料，而使用新的資料。</p><p>=&gt; 使用map()，將資料處理分割成，符合關鍵字想要強調的部分&lt;strong&gt;，和一般的顯示部分&lt;p&gt;</p><p>=&gt;最後訂閱，將資料儲存在變數中。</p><p>&gt;第52行的 onAutocomplete()方法，將使用者使用滑鼠點擊建議項目後的項目值，賦值到搜尋內容中，並且關閉搜尋建議列表。</p><p>&gt;第58行的 onKeydown()方法，是偵測使用者輸入後，按下鍵盤的上下時，會增減index的值，來顯示不同選取項目；以及輸入enter後，將選取的項目賦值到搜尋內容中。</p><p>結論:</p><p>&gt;在w3school的範例，如果使用Angular來改寫，就要改變原本使用JS生成的html方法，改成用Angular提供的*ngIf或*ngFor之類的語法來寫。</p><p>&gt;使用Angular的架構，可以將原本寫在同一個檔案的程式碼，分散在.ts、.service和.html中，其實是比較好管理的。</p><p>&gt;使用強型別的寫法，在維護上也比較直觀。</p><p>&gt;純粹練習，有問題可以提出XD。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b6977b54bd3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular material checkbox with reactive form observables to monitor form control values]]></title>
            <link>https://medium.com/@HonoraryMarleyans/angular-material-checkbox-with-reactive-form-observables-to-monitor-form-control-values-a56148027548?source=rss-4b8774ec33b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a56148027548</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[notes]]></category>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[reactive-forms]]></category>
            <dc:creator><![CDATA[Honorary Marleyans]]></dc:creator>
            <pubDate>Thu, 14 Jul 2022 15:32:03 GMT</pubDate>
            <atom:updated>2022-07-14T15:32:03.967Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the description from the <a href="https://angular.io/guide/observables-in-angular">official Angular website</a>. Angular makes use of observables as an interface to handle a variety of common asynchronous operations. For example:</p><ul><li>The HTTP module uses observables to handle AJAX requests and responses</li><li>The Router and Forms modules use observables to listen for and respond to user-input events</li></ul><p>First of all, we introduce two general cases with reactive form observable.</p><p>A.1 Monitor the input state: when users stop key in letters for two seconds, app would start to do some job. We write some codes to have a input element for key in. So in xxx.component.html codes like following link</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8a5157b31ee5b6acec1234f2a789358/href">https://medium.com/media/e8a5157b31ee5b6acec1234f2a789358/href</a></iframe><p>A.2 And in the component.ts file, we subscribe to inputSearchForm in ngOnInit to get the change values.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0f7706202babae0334e8943c78089c91/href">https://medium.com/media/0f7706202babae0334e8943c78089c91/href</a></iframe><p>B.1 To prevent users double click the button, and send same request, we can use debounceTime also. In the .html, we set a button event</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bda41eb2e8a9adc7225ae496431bbee1/href">https://medium.com/media/bda41eb2e8a9adc7225ae496431bbee1/href</a></iframe><p>B.2 We use viewChild decorator to get the button and make it as observable in ngAfterViewInit.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/055e2f2ca96cdf1f064094ae26eda191/href">https://medium.com/media/055e2f2ca96cdf1f064094ae26eda191/href</a></iframe><p>B.3 We can see the result. After we click the button, the app would console.log(1) after 2 seconds.</p><p>Here we will use reactive forms and Angular material checkbox component to realize that once<strong> <em>users click multiple checkbox, the web would wait for few seconds before send message.</em></strong></p><p>There are some skills we would use:</p><p>a. Angular reactive form</p><p>b. RxJS operators: debounceTime</p><p>c. Angular material checkbox</p><p>First, we use Angular material, ngFor loop and reactive form to generate our checkbox list.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c6e1ae5fee5920603ad6c8b9eff8d35/href">https://medium.com/media/8c6e1ae5fee5920603ad6c8b9eff8d35/href</a></iframe><p>marketArray is a variable we set our default value, like the following settings</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5422bbcbaf9f1a3bec33b26a320861a5/href">https://medium.com/media/5422bbcbaf9f1a3bec33b26a320861a5/href</a></iframe><p>We can now subscribe to the changes of the checkBox in the ngOnInit function.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e45150caa2bcb451fb867d9213cbffac/href">https://medium.com/media/e45150caa2bcb451fb867d9213cbffac/href</a></iframe><p>Reactive forms have properties that use observables to monitor form control values. The <a href="https://angular.io/api/forms/FormControl">FormControl</a> properties valueChanges and statusChanges contain observables that raise change events. Subscribing to an observable form-control property is a way of triggering application logic within the component class.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a56148027548" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Angular Flex-Layout to achieve Responsive Web Design]]></title>
            <link>https://medium.com/@HonoraryMarleyans/using-angular-flex-layout-to-achieve-responsive-web-design-3b73c8424bc2?source=rss-4b8774ec33b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b73c8424bc2</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[layout]]></category>
            <category><![CDATA[flexbox]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Honorary Marleyans]]></dc:creator>
            <pubDate>Thu, 09 Jun 2022 04:10:39 GMT</pubDate>
            <atom:updated>2022-06-09T04:10:39.908Z</atom:updated>
            <content:encoded><![CDATA[<p>This article is a simple note for using Angular flex-layout module.</p><p>We will display responsive web design when the screen width</p><p><strong>A. Bigger then 960px</strong></p><p><strong>B. Between 960px and 600px</strong></p><p><strong>C. Smaller then 600px</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5b7OLfolb22A5voiQ5cHlA.png" /><figcaption>Layout bigger then 960px</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oiCMS2NP9fP2SyJQA4If7A.png" /><figcaption>Layout between 960px and 600px</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v7EnrokM5tSsYsIHhlGtHg.png" /><figcaption>Layout smaller then 600px</figcaption></figure><p>First of all, you have to install flex-layout in the app. Follow the guide lines in the homepage of <a href="https://github.com/angular/flex-layout">flex-layout</a>.</p><ol><li>Start by installing the Angular Layout library from npm</li></ol><p>npm i -s @angular/flex-layout @angular/cdk</p><p>2. Next, you’ll need to import the Layout module in your app’s module.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/82a94fdc96b4d83a3070944360d4fb72/href">https://medium.com/media/82a94fdc96b4d83a3070944360d4fb72/href</a></iframe><p>The properties we will use in this article are <strong>fxLayout </strong>and <strong>fxFlex</strong>.</p><ul><li><a href="https://github.com/angular/flex-layout/wiki/fxLayout-API">fxLayout</a>: Defines the flow order of child items within a flexbox container.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/170919c29c2c170a9e6d655041c41d8d/href">https://medium.com/media/170919c29c2c170a9e6d655041c41d8d/href</a></iframe><p><strong>fxLayout.xs=&#39;&#39; column &#39;&#39;=&gt; .xs extension </strong>indicates the child tags(they are &lt;div&gt; tag usually) in this div will become column layout when the width of the screen widow less then 600px</p><ul><li><a href="https://github.com/angular/flex-layout/wiki/fxFlex-API">fxFlex</a>: This markup specifies the resizing of its host element within a flexbox container flow.</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aad8df539c5450a6578e28531b708c9b/href">https://medium.com/media/aad8df539c5450a6578e28531b708c9b/href</a></iframe><p>The following table is the breakpoint of flex-layout from <a href="https://github.com/angular/flex-layout/wiki/Responsive-API#mediaqueries-and-aliases">flex-layout</a>.</p><h3><strong>MediaQueries and Aliases</strong>​</h3><p>We can associate breakpoints with mediaQuery definitions using breakpoint <strong>alias(es)</strong>:​</p><figure><img alt="MediaQueries and Aliases" src="https://cdn-images-1.medium.com/max/1024/1*jtZ1Nhi0pEw9O_INMYWJcQ.png" /></figure><p>So here are the codes of the three kinds of responsive web design layout.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/08949bf9d3b437d2e83579d2cf081f47/href">https://medium.com/media/08949bf9d3b437d2e83579d2cf081f47/href</a></iframe><p>And the css file to set the background color of the div tag.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9bcfa0410290f80c6abd63dbd60c031/href">https://medium.com/media/b9bcfa0410290f80c6abd63dbd60c031/href</a></iframe><h3><strong>What we have to know in the flex-layout codes:</strong></h3><p><strong>A. The fxLayout in div tag only affects the first nest div tag it contains.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88a9c535df2aa2ca3c71fa10732b4b3a/href">https://medium.com/media/88a9c535df2aa2ca3c71fa10732b4b3a/href</a></iframe><p><strong>B. Once we use a fxLayout in parent div, we should set fxFlex in child div to set the width of height.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/11a6c13ad45394272cee68c3bdb6fed6/href">https://medium.com/media/11a6c13ad45394272cee68c3bdb6fed6/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b73c8424bc2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Angular view encapsulation_three modes demo]]></title>
            <link>https://medium.com/@HonoraryMarleyans/angular-view-encapsulation-four-modes-demo-4216d92efed9?source=rss-4b8774ec33b------2</link>
            <guid isPermaLink="false">https://medium.com/p/4216d92efed9</guid>
            <category><![CDATA[html]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[shadow-dom]]></category>
            <category><![CDATA[encapsulation]]></category>
            <dc:creator><![CDATA[Honorary Marleyans]]></dc:creator>
            <pubDate>Thu, 07 Apr 2022 03:57:44 GMT</pubDate>
            <atom:updated>2022-04-07T04:01:01.244Z</atom:updated>
            <content:encoded><![CDATA[<p>In Angular, a component’s styles can be encapsulated within the component’s host element so that they don’t affect the rest of the application.</p><p>We can set three modes in xxxx.component.ts, as the following code shows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6515b96247e6831963a70ac2663144dc/href">https://medium.com/media/6515b96247e6831963a70ac2663144dc/href</a></iframe><p>The three modes are:</p><p><a href="https://angular.io/api/core/ViewEncapsulation#ShadowDom">ViewEncapsulation.ShadowDom</a>: It neither affects nor is affected by other components. <strong>And if we use this setting in a parent component, child components in this parent folder will be affected by parent’s .css file setting. </strong>The parent component becomes a shadow root.</p><p><a href="https://angular.io/api/core/ViewEncapsulation#Emulated">ViewEncapsulation.Emulated</a>: It it the default setting in Angular. Actually if we want to take advantage of Angular, we don’t need to change anything about encapsulation. In this mode, the component style would be affected only by global style setting. Style settings in a component wouldn’t affect or be affected by other components.</p><p><a href="https://angular.io/api/core/ViewEncapsulation#None">ViewEncapsulation.None</a>: The style settings in a component would affect either parent or child components.</p><h4><strong>About angular </strong><a href="https://angular.io/api/core/ViewEncapsulation"><strong>ViewEncapsulation.Emulated</strong></a></h4><p><a href="https://angular.io/api/core/ViewEncapsulation">ViewEncapsulation.Emulated</a> is the recommended and default mode.</p><p>In the DOM of a running Angular application, elements belonging to components using emulated view encapsulation have some extra attributes attached to them:</p><p>&lt;hero-details _<strong>nghost</strong>-pmm-5&gt;</p><p>&lt;h2 _ngcontent-pmm-5&gt;Mister Fantastic&lt;/h2&gt;</p><p>&lt;hero-team _<strong>ngcontent</strong>-pmm-5 _nghost-pmm-6&gt;</p><p>&lt;h3 _ngcontent-pmm-6&gt;Team&lt;/h3&gt;</p><p>&lt;/hero-team&gt;</p><p>&lt;/hero-detail&gt;</p><p>There are two kinds of such attributes:</p><p>•_<strong>nghost</strong> attributes are added to elements that enclose a component’s view and that would be ShadowRoots in a native Shadow DOM encapsulation. This is typically the case for components’ host elements.</p><ul><li>_<strong>ngcontent </strong>attributes are added to child element within a component’s view, those are used to match the elements with their respective emulated ShadowRoots (host elements with a matching _nghost attribute).</li></ul><h4>Demos about the three settings</h4><p>I would show four cases with my angular lesson example, the following picture shows the layout of components.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bMEg0KBFA04hthmSWdqCnQ.png" /></figure><p><strong>app-classfive</strong> is the parent component</p><p><strong>app-cockpit</strong> and <strong>app-server-element </strong>are child components in the <strong>app-classfive component </strong>folder.</p><p>In global style settings, Bootstrap is used to set the button and input style.</p><p><strong><em>Case 1</em></strong></p><p>Set <strong>encapsulation:ViewEncapsulation.None</strong> in <strong>child component server-element.component.ts</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZJ9XTu6lSZwcvbRaaRetog.png" /></figure><p>I set ncapsulation:ViewEncapsulation.None in server-element.component.ts and define the elements &lt;p&gt; and &lt;label&gt; style in serve-element.component.css file.</p><ul><li>The &lt;p&gt; and &lt;label&gt; elements in the other child component cockpit are affected by the settings in server-element.css.</li><li>The &lt;label&gt; element in parent component is affected by the settings in server-element.css.(<em>The statement in classfive.html==&gt; Label…….</em>)</li><li>The &lt;p&gt; element in server-element is defined with the following codes in .html, so it still remains the color <strong>red</strong>.</li></ul><p>=&gt;&lt;p style=”color: red&quot;&gt;just test&lt;/p&gt;</p><p><strong><em>Case 2</em></strong></p><p>Set <strong>encapsulation:ViewEncapsulation.None</strong> in <strong>parent component classfive.component.ts</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DIeDw8FcPXVsw6a0ML5rDA.png" /></figure><p>I set ncapsulation:ViewEncapsulation.None in classfive.component.ts and define the element &lt;label&gt; style in classfive.component.css file. And I also remove the style settings(in .css file) in any child components.</p><ul><li>The &lt;label&gt; element in child component server-element is affected by the setting in parent component.</li><li>The &lt;p&gt; element shows the default style cause it is not set by any other .css file.</li></ul><p><strong><em>Case 3</em></strong></p><p>Set <strong>encapsulation:ViewEncapsulation.ShadowDom</strong> in <strong>parent component classfive.component.ts</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BrSUQUHT6EXE6ErW6BmMMQ.png" /></figure><p>I set ncapsulation:ViewEncapsulation.ShadowDom in classfive.component.ts and define the element &lt;label&gt; style in classfive.component.css file.</p><ul><li>The &lt;input&gt; and &lt;button&gt; elements wouldn’t be affected by the bootstrap style global setting.</li><li>The style settings in parent .css file<strong> STILL Affect </strong>the &lt;label&gt; element in child component.</li><li>The attributes in the elements defined by angular disappear.</li></ul><p><strong><em>Case 4</em></strong></p><p>Set <strong>encapsulation:ViewEncapsulation.ShadowDom</strong> in both <strong>parent component classfive.component.ts </strong>and <strong>child component cockpit.component.ts</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qXF8bGltKaMddkhZXteeMQ.png" /></figure><p>I set ncapsulation:ViewEncapsulation.ShadowDom in classfive.component.ts and cockpit.component.ts<strong>, </strong>and I define the element &lt;label&gt; style in classfive.component.css file.</p><ul><li>The &lt;input&gt; and &lt;button&gt; elements wouldn’t be affected by the bootstrap style global setting.</li><li>The style settings in parent .css file <strong>WOULD NOT</strong> A<strong>ffect</strong> the &lt;label&gt; element in child component.</li></ul><p><strong>Conclusion</strong></p><p>Just like the statements in this article in the beginning:</p><p><strong><em>ViewEncapsulation.Emulated</em></strong><em> </em>is<em> the default setting in Angular. Actually if we want to take advantage of Angular, we don’t need to change anything about encapsulation. We even don’t have to add any code.</em></p><p>The cases are just for sharing to the use in some particular situations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4216d92efed9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>