title: Angular *ngIf check if key exists in map
body: <p>I have a map that looks like:</p>
  
  <pre><code>let mapToSearch =
  {
    'aaa': '123',
    'bbb': '456'
  }
  </code></pre>
  
  <p>and I have a variable:</p>
  
  <pre><code>let keyToFind = 'aaa';
  </code></pre>
  
  <p>In my HTML template, in an Angular <code>*ngIf</code> block, I want to check if <code>keyToFind</code> matches any key within this map.</p>
  
  <p>Something like JS <code>array.indexOf()</code>:</p>
  
  <pre><code>&lt;ng-container *ngIf="mapToSearch.indexOf(keyToFind)"&gt;
    Hello world
  &lt;/ng-container&gt;
  </code></pre>
  
  <p>Is such a thing possible with maps within a template?</p>
  
  <hr>
  
  <p><strong>Update (including Solution)</strong></p>
  
  <p>Thanks for all your answers. All your answers are valid for working with a object literal (this was my mistake - I should have declared the map differently in the question).</p>
  
  <p>However, for a ES6 map, I discovered I can use <code>map.has(key)</code> in the template.</p>
  
  <p>Declare map with <code>map.set()</code>: </p>
  
  <pre><code>let mapToSearch = new Map();
  mapToSearch.set('aaa', '123'};
  mapToSearch.set('bbb', '456'};
  </code></pre>
  
  <p>Template:</p>
  
  <pre><code>&lt;ng-container *ngIf="mapToSearch.has(keyToFind)"&gt;
    Hello World
  &lt;/ng-container&gt;
  </code></pre>
  
  <p><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/has</a></p>