title: How to switch the image based on the selected gender in angularjs
body: <p>Im very new to angularjs.what im trying to do is just to assign differnt images to a user based on the selected gender(took the value from the textfield.),ie 
  if gender==male{
  male image.
  }
  else{
  female image.
  }</p>
  
  <p>im just saving the text from the text field into an array,</p>
  
  <p>saving code:</p>
  
  <pre><code>$scope.save = function () {
              var contact = {'name':$scope.name,'phone':$scope.phone,'email':$scope.email,'gender':$scope.gender};
              var arrayOfObject = [];
              if (localStorage.getItem('data') == null || localStorage.getItem('data') == '') {
                  arrayOfObject.push(contact);
              }
              else {
                  arrayOfObject = JSON.parse(localStorage.getItem('data'));
                  arrayOfObject.push(contact);
              }
  
          localStorage.setItem('data', JSON.stringify(arrayOfObject));
          console.log('array is:',localStorage);
  
    }
  </code></pre>
  
  <p>retrieving code:</p>
  
  <pre><code>var completeList = [];
      $scope.completeList = myService.getData();
  
      if($scope.completeList!==null &amp;&amp; $scope.completeList!==0){
  
  
      for(var i=0; i &lt;$scope.completeList.length; i++)
      {
  
          $scope.gender = $scope.completeList[i].gender;
  
          if($scope.gender == "female"){
           $scope.image1= 'images/female.jpg';
          }
          else{
          $scope.image1 = 'images/profile.png';
          }
          console.log($scope.image1);
      }
  </code></pre>
  
  <p>in html page</p>
  
  <pre><code>&lt;tr ng-repeat="n in completeList| filter:search"&gt;
            &lt;td ng-click="detailView($index)"&gt;
               &lt;div&gt;&lt;img width="100px" height="50px"  ng-src="{{image1}}" &gt;&lt;/div&gt;
  </code></pre>
  
  <p>But the problem is html is only dispalying the image i saved lastly into the array(ie if i save last object as "male",it is dispalying only males images by replacing all the female images and vice-versa..</p>
  
  <p>Can anyone please help me where im going wrong.</p>
  
  <p>Thanks in advance.</p>