title: Skip or replace undefined value from result set (API call) in angular
body: <p>I'm querying an API which gives back a list of results. The model is the following.</p>
  
  <pre><code>result
       {id1
       name1
       fieldList1{}
       }
  
       {id2
       name2
       fieldList2{}
       }
  
       {id3
       name3
       fieldList3{}
       }
  </code></pre>
  
  <p>fieldList1, fieldList2 and fieldList3 are an array of the following fields.</p>
  
  <pre><code>fieldList1
       id
       field1
       field2
  </code></pre>
  
  <p>The problem I'm facing is that field2 is not always defined because it's not in the returned results, but I want it in my own model. So field2 is required and I want (if the field is not there) replace it with an 0. So I can show an replacement message in the html if it's 0.</p>
  
  <p>I tried with the following code to loop over the results, put it in a new array and replace if undefined:</p>
  
  <pre><code>this.resultList.push({id: i.id, field1:  i.field1, field2: i.field2 ? 0 : i.field2});
  </code></pre>
  
  <p>This still gives me the undefined error message and when I switch the if statement all my field2's are put on 0 even if it was there.</p>