title: Edit record needs page refresh
body: <p>All is working well but when i insert a record and try to edit the same record it will not get edited and to edit the same record i have to refresh page and same happens in update ,once record is updated i have to refresh the page to edit same record </p>
  
  <pre><code>&lt;html ng-app="crudApp"&gt;
      &lt;head&gt;
          &lt;meta charset="UTF-8"&gt;
          &lt;title&gt;Angular js&lt;/title&gt;
          &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"&gt;&lt;/script&gt;
          &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body ng-controller="DbController"&gt;
          &lt;form   id="form" name="employee"&gt;
              First Name: &lt;input type="text" ng-model="firstname"&gt;&lt;br/&gt;&lt;br/&gt;
              Last Name: &lt;input type="text" ng-model="lastname"&gt;&lt;br/&gt;&lt;br/&gt;
              &lt;input type="submit" name="btnInsert" id="Insert" value="Insert" ng-click='insertData()'/&gt;
              &lt;input type="submit" name="btnUpdate" id="Update"value="Update" ng-click='UpdateData(currentUser)'/&gt;
          &lt;/form&gt;
  
          &lt;div&gt;
              &lt;table border="1"&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Firstname&lt;/th&gt;
                      &lt;th&gt;Lastname&lt;/th&gt;
                      &lt;th&gt;Delete&lt;/th&gt;
                      &lt;th&gt;Edit&lt;/th&gt;
                  &lt;/tr&gt; 
                  &lt;tr ng-repeat="detail in details"&gt;
                      &lt;td&gt;{{detail.firstname}}&lt;/td&gt;
                      &lt;td&gt;{{detail.lastname}}&lt;/td&gt;
                      &lt;td&gt;&lt;input type="button" value="Delete"  ng-click="deleteInfo(detail.id)"/&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;input type="button" value="Edit"  ng-click="editInfo(detail.id)"/&gt;&lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
          &lt;/div&gt;
          &lt;script&gt;
                      var crudApp = angular.module('crudApp', []);
                      crudApp.controller("DbController", ['$scope', '$http', function ($scope, $http) {
  
                              getInfo();
                              function getInfo() {
                                  $http.post('select.php').success(function (data) {
                                      // Stored the returned data into scope
                                      $scope.details = data;
                                  });
                              }
  
                              $scope.deleteInfo = function (info) {
                                  $http.post('delete.php', {del_id: info
                                  }).success(function (result) {
                                      getInfo()
                                      console.log(result);
                                  });
                              }
  
                              $scope.insertData = function () {
                                  $http.post("insert.php", {
                                      'firstname': $scope.firstname,
                                      'lastname': $scope.lastname,
                                  }).success(function () {
                                      getInfo();
                                      document.getElementById("form").reset();
                                  });
                              }
  
  
                              $scope.editInfo = function (info) {
                                  $scope.currentUser = info;
                                  $http.post('edit.php', {edit_id: $scope.currentUser,
                                  }).success(function (result) {
                                      $scope.firstname = result[0]['firstname'],
                                              $scope.lastname = result[0]['lastname'],
                                              $("#Insert").hide();
                                      $("#Update").show();
                                  });
                              }
  
                              $scope.UpdateData = function (currentUser) {
                                  $http.post("update.php", {
                                      'firstname': $scope.firstname,
                                      'lastname': $scope.lastname,
                                      'update_id': currentUser,
                                  }).success(function (result) {
                                      getInfo();
                                      $("#Insert").show();
                                      $("#Update").hide();
                                      document.getElementById("form").reset();
                                  });
                              }
  
                          }]);
  
          &lt;/script&gt;
  
      &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>