title: Angular Search for value in JSON and display corresponding data
body: <p>What i am trying to do is simple. A user enters a value, on button click, my JS calls a service to retreive my JSON data and perform a search on the value entered against the JSON and if a match is found, display the 'Owner'.</p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;div ng-app="myApp"&gt;
      &lt;div ng-controller="MainCtrl"&gt;
          &lt;input type="text" ng-model="enteredValue"&gt;
          &lt;/br&gt;
          &lt;button type="button" ng-Click="findValue(enteredValue)"&gt;Search&lt;/button&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>JS:</strong></p>
  
  <pre><code>angular.module('myApp', []).controller('MainCtrl', function ($scope, $http, getDataService) {   
  
      $scope.findValue = function(enteredValue) {     
          alert("Searching for = " + enteredValue);
  
          $scope.MyData = [];
  
          getDataService.getData(function(data) {
  
              $scope.MyData = data.SerialNumbers;
  
          });
      }
  
  });
  
  angular.module('myApp', []).factory('getDataService', function($http) {
      return {
          getData: function(done) {
              $http.get('/route-to-data.json')
              .success(function(data) { 
                  done(data);
              })
              .error(function(error) {
                  alert('An error occured');
              });
          }
      }
  });
  </code></pre>
  
  <p><strong>My JSON:</strong></p>
  
  <pre><code>{
      "SerialNumbers": {
          "451651": [
              {
                  "Owner": "Mr Happy"
              }
          ],
          "5464565": [
              {
                  "Owner": "Mr Red"
              }
          ],
          "45165": [
              {
                  "Owner": "Mr Sad"
              }
          ],
          "4692": [
              {
                  "Owner": "Mr Green"
              }
          ],
          "541": [
              {
                  "Owner": "Mr Blue"
              }
          ],
          "D4554160N": [
              {
                  "Owner": "Mr Loud"
              }
          ]
      }
  }
  </code></pre>
  
  <p>Here's my fiddle: <a href="http://jsfiddle.net/oampz/7bB6A/" rel="noreferrer">http://jsfiddle.net/oampz/7bB6A/</a></p>
  
  <p>I am able to call my service, and retrieve the data from the JSON, but i am stuck on how to perform a search on my retrieved data against the value entered.</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>The following finds a serialnumber entered:</p>
  
  <pre><code>angular.forEach($scope.MyData, function(value, key) {
              if (key === enteredValue) {
                  console.log("I Found something...");
                  console.log("Serial: " + key);
                  console.log("Owner: " + key.Owner);
              }
  
          })
  </code></pre>
  
  <p>I can display the found serialNumber via <code>console.log("Serial: " + key);</code> but trying to display the Owner as <code>console.log("Owner: " + key.Owner);</code> is showing as <em>Undefined</em>.</p>