title: Angular Filter Data by id
body: <p>I have some data in an angular project which I want to use instead of a database as it's very little data...about 50 id's with 5 fields...here is the data:</p>
  
  <pre><code>mydata = [
  
    {
      "id": 3,
      "active": 1,
      "title": "Title 1",
      "text": "this is some text from 3"
    },
    {
      "id": 31,
      "active": 1,
      "title": "Title 1",
      "text": "this is some text from 31"
    },
    {
      "id": 11,
      "active": 1,
      "title": "Title 1",
      "text": "this is some text for 11"
    },
    {
      "id": 21,
      "active": 1,
      "title": "Title 1",
      "text": "this is some text from 21"
    }
  
  ]
  </code></pre>
  
  <p>Then I have a method:</p>
  
  <pre><code>getDataText(id) {
      // code to get the text of the data with the selected id
      // do it should get me the data (in this case the text from id 11) 
  }
  </code></pre>
  
  <p>Then in the component.html file I have:</p>
  
  <pre><code>&lt;button (click)="getDataText(11)"&gt;Get Data by Id&lt;/button&gt;
  </code></pre>
  
  <p>How can I do this?</p>