title: Angular 5 how to add ngClass of component's elements from parent HTML
body: <p>My project has one angular component nested inside a main html file. It's rendered using  angular selector. </p>
  
  <p>and component1 has divs inside which I'm trying to dynamically add &amp; remove their CSS classes using ngClass. </p>
  
  <p>But the button that will trigger that change is nested in the main HTML, not inside the component. </p>
  
  <p>I tried EventEmitter from main html but I learned EventEmitter doesn't work for parent to child element interaction. It works only for child element (component) to parent interaction. So I think I have to create a service provider which transfers button's function to component divs from main html.
  But I have no idea how..</p>
  
  <p>Here's my main html: </p>
  
  <pre><code>&lt;component1&gt;&lt;/component&gt;
  
  &lt;button (click)="addStyles()"&gt;&lt;/button&gt;
  &lt;button (click)="removeStyles()"&gt;&lt;/button&gt;
  </code></pre>
  
  <p>and here's my component HTML file: </p>
  
  <pre><code>&lt;div [ngClass]="exampleDiv01"&gt;&lt;/div&gt;
  &lt;div [ngClass]="exampleDiv02"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>and here's my component SCSS file: </p>
  
  <pre><code>style-added {
   background: red;
  width: 400px;
  height: 400px;
   }
  
  style-removed {
   background: white;
  width: 200px;
  height: 200px;
  }
  </code></pre>
  
  <p>How can I make my main HTML's two buttons to dynamically add style-added, style-removed classes to component's exampleDiv01 using provider? </p>
  
  <p>Any opinion would be appreciated! </p>
  
  <p>Thanks,</p>