title: Angular ngClass with condition
body: <p>I am getting data from JSON file instead of database. I am trying to give color to the Icon based on the value of status in JSON for example [if green? class1:class2] below is my code.</p>
  <p><strong>My HTML file</strong></p>
  <pre><code>   &lt;ng-container matColumnDef=&quot;status&quot; [ngClass] = &quot;{'color1': row.status === 
          'GREEN', 'color2': row.status === 'RED'}&quot;&gt;
          &lt;th mat-header-cell *matHeaderCellDef mat-sort-header&gt;Status&lt;/th&gt;
          &lt;td mat-cell *matCellDef=&quot;let row&quot; class=&quot;color1&quot;&gt;{{row.status}}&lt;/td&gt;
          &lt;td mat-cell *matCellDef=&quot;let row&quot; class=&quot;color2&quot;&gt;{{row.status}}&lt;/td&gt;
      &lt;/ng-container&gt;
  </code></pre>
  <p><strong>Below is my JSON file</strong>.</p>
  <pre><code>    data:[
            {
             &quot;name&quot;: &quot;xyz&quot;,
             &quot;address&quot;: &quot;post&quot;,
             &quot;status&quot;: &quot;GREEN&quot;
            },
            {
             &quot;name&quot;: &quot;xyz1&quot;,
             &quot;address&quot;: &quot;post1&quot;,
             &quot;status&quot;: &quot;RED&quot;
             }
           ],
         &quot;count&quot; : 2
  }
  </code></pre>
  <p><strong>This is my CSS</strong></p>
  <pre><code>.color1{
    color: green;
  }
  
  .color2{
    color: red;
  }
  </code></pre>
  <p>** I could not able to change color of status icon. And I got this error **</p>
  <p><em>ERROR TypeError: Cannot read property 'status' of undefined</em></p>