title: Assign a class to a div inside *ngFor based on condition
body: <p>I need to assign a class to a div that is inside a *ngFor iteration, based on a method.</p>
  <p>Below is my HTML code: -</p>
  <pre><code>&lt;ng-container *ngFor=&quot;let data of totalData let j = index&quot;&gt;
            &lt;div&gt;
              &lt;a (click)=&quot;selectData(data)&quot;&gt;
                &lt;div [ngClass]=&quot;{selected : selectedCodeMethod(data)}&quot;&gt;
                  {{data.code}}
                &lt;/div&gt;
              &lt;/a&gt;
            &lt;/div&gt;
          &lt;/ng-container&gt;
  
  </code></pre>
  <p>My Ts code:-</p>
  <pre><code>selectedCodeMethod(data){
     if(this.selectedCode.includes(data.code)){
               return true;
       }
               return false;
  }
  
  selectData(data){
      this.selectedCode.push(data.code);
  }
  
  </code></pre>
  <p>Even if the selectedCodeMethod() changes the content of selectedCode array, the method inside ngClass doesn't reflect changes.</p>
  <p>What changes do I need to make?</p>