<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Salman Kazmi</title>
    <description>The latest articles on DEV Community by Salman Kazmi (@salmankazmi6).</description>
    <link>https://dev.to/salmankazmi6</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F141303%2F77b973f0-20ca-43f2-a5bd-055fb8833abc.jpg</url>
      <title>DEV Community: Salman Kazmi</title>
      <link>https://dev.to/salmankazmi6</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/salmankazmi6"/>
    <language>en</language>
    <item>
      <title>Content Projection in Angular - Part 2</title>
      <dc:creator>Salman Kazmi</dc:creator>
      <pubDate>Wed, 06 Nov 2019 18:04:34 +0000</pubDate>
      <link>https://dev.to/salmankazmi6/content-projection-in-angular-part-2-36hj</link>
      <guid>https://dev.to/salmankazmi6/content-projection-in-angular-part-2-36hj</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;In the previous &lt;a href="https://dev.to/salmankazmi6/content-projection-in-angular-34a5"&gt;article&lt;/a&gt; on this topic, I touched the basics of Content Projection with Angular and how easily one can work with dynamic templates without much fuss. I also discussed the use case where one may need to project content to a Component dynamically.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Continuing in this post, I will touch some advanced use case scenarios where we can leverage the power that Angular provides.&lt;/p&gt;

&lt;p&gt;Now, to discuss further, a Component provides us a functionality where we may pass the template in between the opening and closing braces of the component where we use it as a child in our template.&lt;/p&gt;

&lt;p&gt;Like &lt;code&gt;&amp;lt;demo&amp;gt;&amp;lt;h1&amp;gt;This is the template for content projection&amp;lt;/h1&amp;gt;&amp;lt;/demo&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The contents of the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; tag will be displayed where &lt;code&gt;&amp;lt;ng-content&amp;gt;&lt;/code&gt; tag is present in the child i.e., demo component.&lt;/p&gt;

&lt;p&gt;What if the child has several &lt;code&gt;&amp;lt;ng-content&amp;gt;&lt;/code&gt; tags. How can we pass the template to a particular &lt;code&gt;&amp;lt;ng-content&amp;gt;&lt;/code&gt; tag thereby rendering the dynamic view to its correct position?&lt;/p&gt;

&lt;p&gt;Let's discuss Targeted Projection.&lt;/p&gt;

&lt;p&gt;Angular provides us with the &lt;code&gt;select&lt;/code&gt; attribute of the &lt;code&gt;ng-content&lt;/code&gt; tag. With this attribute, we can actually work with targeted projection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use case 1:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;ng-content select="[first-place]"&amp;gt;&amp;lt;/ng-content&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The template can be passed as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;demo&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;first-place&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Hello World!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/demo&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Use case 2:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;ng-content select="[place='first']"&amp;gt;&amp;lt;/ng-content&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;ng-content select="[place='second']"&amp;gt;&amp;lt;/ng-content&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The template can be passed as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;demo&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;place=&lt;/span&gt;&lt;span class="s"&gt;'first'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Content 1&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;place=&lt;/span&gt;&lt;span class="s"&gt;'second'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Content 2&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/demo&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Use case 3:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;ng-content select=".place-first"&amp;gt;&amp;lt;/ng-content&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;code&gt;&amp;lt;ng-content select=".place-second"&amp;gt;&amp;lt;/ng-content&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;The template can be passed as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;demo&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;'place-first'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Content 1&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;'place-second'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Content 2&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/demo&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;There are a few other use cases as well, which I will keep for some other day to discuss. I hope this post proves to be useful in you Angular learning journey. Cheers!&lt;/p&gt;

</description>
      <category>angular</category>
      <category>contentprojection</category>
      <category>dynamicviews</category>
    </item>
    <item>
      <title>High time we discussed Mental Health</title>
      <dc:creator>Salman Kazmi</dc:creator>
      <pubDate>Tue, 05 Nov 2019 13:12:23 +0000</pubDate>
      <link>https://dev.to/salmankazmi6/high-time-we-discussed-mental-health-2hm2</link>
      <guid>https://dev.to/salmankazmi6/high-time-we-discussed-mental-health-2hm2</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hazy Mornings. Brain Fog. Lack of Clarity.&lt;/strong&gt; These symptoms may sound familiar to today’s knowledge worker. In these times where people are measured in terms of productivity and output, talking to someone about Mental Health issues is frowned upon. It is acceptable if one is physically unfit, is down with fever or is having a mild body ache but taking some time off to declutter your brain is I believe is not cool and is laughed off generally.&lt;/p&gt;

&lt;p&gt;For knowledge workers like us, it is imperative and very important to discuss mental health issues and find out effective solutions and remedies that make us perform to the best of our abilities and get rid of depression, anxiety and lack of clarity towards our goals. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In this short article, I try to suggest some steps that can be undertaken by all of us regardless of the fact this modern epidemic hit us or not. Let’s start with point number one:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Conversation&lt;/strong&gt;: We are social animals. We need company to survive. Period. Having a conversation with our fellow beings is not only important but a necessity. In these days of fast-paced technological innovations and connectivity, we are more disconnected from each other ever.&lt;br&gt;
Technology helps us communicate but is not able to provide that human touch. Sort this communication thing in your life for better mental health. Find a person of two to chit chat in the office. Discuss your thoughts and feelings and take feedback. Believe me, it works.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Physical Fitness&lt;/strong&gt;: A healthy mind resides in a healthy body. How aptly said. Be more physically fit from today onwards. Take those stairs. Eat healthy. Find time to take a casual walk in nature.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Planning&lt;/strong&gt;: If you are failing to plan, you are planning to fail. Remember this and plan your day well in advance. Leave a few things to chance. Maintain a journal and write about the things you do in a day. It will help you understand where you spend your time thus proving beneficial in your plans. Try to lead life according to a routine. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Free Time&lt;/strong&gt;: Throw those gadgets away for a while in the day and enjoy peace of mind. Sometimes not doing anything is also a great remedy. Enjoy your free time. Try meditation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Get rid of negativity&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Be closer to nature&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
&lt;p&gt;It is very important to take care of your mind. It is ultimately the most prized resource we have.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Please share the techniques you use to declutter and how you stay on top of your game.&lt;/p&gt;

</description>
      <category>mentalhealth</category>
      <category>softwaredevelopment</category>
      <category>health</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Content Projection in Angular - Part 1</title>
      <dc:creator>Salman Kazmi</dc:creator>
      <pubDate>Mon, 04 Nov 2019 18:14:45 +0000</pubDate>
      <link>https://dev.to/salmankazmi6/content-projection-in-angular-34a5</link>
      <guid>https://dev.to/salmankazmi6/content-projection-in-angular-34a5</guid>
      <description>&lt;p&gt;One of the more advanced topics in the study of the Angular framework is content projection. To understand this very important and interesting topic, we need to have a good understanding of how components work in Angular.&lt;/p&gt;

&lt;p&gt;In this brief article, I try to explain what Content Projection actually is and what are the different ways Angular provides you to leverage this powerful feature.&lt;/p&gt;

&lt;p&gt;Basically, content projection is a way by which we can provide an external template to a component thereby giving us the functionality to provide a template to a particular component to render. The component providing content projection may or may not have its own template.&lt;/p&gt;

&lt;p&gt;Let’s look at a very basic example:&lt;/p&gt;

&lt;p&gt;I have a component named demo as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&amp;lt;h1&amp;gt;Hello {{name}}!&amp;lt;/h1&amp;gt;`&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;HelloComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;John!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;As we can see we have a variable defined ‘name’ that we use to show the name on the component’s template. If we change the name to some other, it is reflected in the template. We can also make it as an &lt;code&gt;@Input&lt;/code&gt; to take the value of ‘name’ from the parent component where this component would be used. Eg. &lt;code&gt;@Input()name: string = 'John!'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;So, now the use case for content projection kicks in. What if I wanted the user to provide the heading tag along with the name of the user. He can provide an &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; or an &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; tag along with the name as it suits him. This is where Angular’s content projection kicks in.&lt;/p&gt;

&lt;p&gt;Let’s take another example to understand better:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`&amp;lt;ng-content&amp;gt;&amp;lt;/ng-content&amp;gt;`&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;HelloComponent&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Look closely, in this example, we have used a tag called &lt;code&gt;ng-content&lt;/code&gt; provided to us by Angular to render a dynamic template that would be passed by the parent where this component would be used.&lt;/p&gt;

&lt;p&gt;So, if I have a parent component say, DemoComponent as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;demo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;template&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`
   &amp;lt;hello&amp;gt;&amp;lt;h1&amp;gt;Hello John!&amp;lt;/h1&amp;gt;&amp;lt;/hello&amp;gt;
   &amp;lt;hello&amp;gt;&amp;lt;h5&amp;gt;Hello Doe!&amp;lt;/h5&amp;gt;&amp;lt;/hello&amp;gt;
  `&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;DemoComponent&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here we can see that I have used the HelloComponent as a child twice passing different templates each time between the opening and closing tags. Actually we can pass a complete HTML template that would be rendered where &lt;code&gt;&amp;lt;ng-content&amp;gt;&lt;/code&gt; is presently placed in the child (hello) component.&lt;/p&gt;

&lt;p&gt;This is a very basic example to demonstrate how a template can be passed to a component thereby making the component's template dynamic. At its very core, content projection in Angular is pretty powerful offering various techniques to handle passed template which we will discover in the upcoming posts.&lt;/p&gt;

&lt;p&gt;Hope you found this article useful.&lt;/p&gt;

</description>
      <category>angular</category>
      <category>angularcontentprojection</category>
      <category>contentprojection</category>
      <category>dynamicviews</category>
    </item>
    <item>
      <title>A Case Against Open Floor Offices</title>
      <dc:creator>Salman Kazmi</dc:creator>
      <pubDate>Sun, 03 Nov 2019 08:12:39 +0000</pubDate>
      <link>https://dev.to/salmankazmi6/a-case-against-open-floor-offices-5286</link>
      <guid>https://dev.to/salmankazmi6/a-case-against-open-floor-offices-5286</guid>
      <description>&lt;p&gt;Alright, let me begin with my own experience with working on so-called team-building open floor offices that are the rage with IT companies these days. Honestly, the experience has been one on the downside and I personally prefer a place to work that is quiet and fosters imagination, creativity and the so-called Deep Work. &lt;/p&gt;

&lt;p&gt;I, like many of you, work in the area of Software Development and quite frankly, it requires bouts of concentration and focus to get work done efficiently. I have worked in many different office spaces before and sadly most of the places had this open office floor trend. In general, I prefer to have no grudges with working in an open environment where one is easily reachable and communication flows freely, but especially for this one particular area which I discuss in this post, I strongly believe that the culture that open offices promote is not very conducive to effective work.&lt;/p&gt;

&lt;p&gt;Effective Software Development, for once requires considerable amounts of focus and attention to detail to get the job done. WIth constant chatters, murmurs, and activity going in and around the office floor, the mind constantly is forced to get its attention diverted from the task at hand.&lt;/p&gt;

&lt;p&gt;Our attention span is quite limited and the way we human beings are manufactured, we pretty much suck at multi-tasking. In order for us to concentrate fully on a given task, hands-on coding, for instance, we require constant undiverted attention.&lt;/p&gt;

&lt;p&gt;I believe what we as programmers can achieve with constant focus and concentration in a given time far outweighs when the attention is diverted often. The mind consumes a lot of energy when it shifts attention from one task to another. So if we constantly try to focus on our work and there are distractions nearby, it fails to concentrate and is forced to multitask which in turn is very taxing in terms of energy consumption.&lt;/p&gt;

&lt;p&gt;I strongly believe that open-floor offices with all their happenings, chit-chats and on-demand availability work culture is not at all helping in fostering growth and productivity.&lt;/p&gt;

&lt;p&gt;No wonder we accomplish far more in the days we work from home or from a peaceful place like a library. The topic is debatable but I have my priorities sorted.&lt;/p&gt;

&lt;p&gt;What do you think? Please share your thoughts in the comments below.&lt;/p&gt;

&lt;p&gt;Have a productive week ahead!&lt;/p&gt;

</description>
      <category>office</category>
      <category>workculture</category>
      <category>teamwork</category>
      <category>softwaredevelopment</category>
    </item>
  </channel>
</rss>
