2016-08-01 3 views
0

올바른 절차를 수행 했더라도 삭제 기능에 대해 경고를받을 수 없으므로 동일한 도움을주십시오. 내 문제를 해결하기 위해 미리 감사드립니다. 경고를받을 수 없습니다. 삭제 기능을 위해 내가 잘 절차를 완료 한 경우에도 그래서 당신의 각도 응용 프로그램의 한 부분으로 등록해야Angular Js에서 삭제 기능이 작동하지 않습니다

<html ng-app="crudApp"> 
    <head> 
     <meta charset="UTF-8"> 
     <title>Angular js</title> 
     <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script> 
    </head> 

    <body> 
     <form name="addForm" ng-submit="Add" ng-controller="employeecontroller"> 
      First Name: <input type="text" ng-model="firstname"><br/><br/> 
      Last Name: <input type="text" ng-model="lastname"><br/><br/> 
      <input type="submit" name="btnInsert" value="Insert" ng-click='insertData()'/> 
     </form> 

     <div ng-controller="DbController"> 
      <table border="1"> 
       <tr> 
        <th>Firstname</th> 
        <th>Lastname</th> 
       </tr> 
       <tr ng-repeat="detail in details"> 
        <td>{{detail.firstname}}</td> 
        <td>{{detail.lastname}}</td> 
        <td><input type="button" value="Delete" ng-click="deleteInfo()"/></td> 
       </tr> 
      </table> 

     </div> 
     <script> 

      function employeecontroller($scope, $http) { 
       $scope.insertData = function() { 
        $http.post("insert.php", { 
         'firstname': $scope.firstname, 
         'lastname': $scope.lastname, 
        }).success(function (data, status, headers, config) { 
         console.log("Data Inserted Successfully"); 
        }); 
       } 
      } 

      var crudApp = angular.module('crudApp', []); 
      crudApp.controller("DbController", ['$scope', '$http', function ($scope, $http) { 
        // Sending request to EmpDetails.php files 
        getInfo(); 
        function getInfo() { 
         $http.post('select.php').success(function (data) { 
          // Stored the returned data into scope 

          $scope.details = data; 

          console.log(data); 
         }); 
        } 
       }]); 

      function DbController($scope,$http) { 

       $scope.deleteInfo = function() { 
        alert("hello"); 

       } 
      } 

     </script> 

    </body> 

</html> 
+0

'employeecontroller'로 작업 했습니까? 앱에 등록되지 않은 것처럼 보입니다. 오류가 없습니까? – AranS

+0

자신을 반복 할 필요가 없습니다 ... –

답변

1

내 문제 각각의 컨트롤러를 해결하기 위해 사전에 same.Thanks 저를 도와주세요. DbController을 등록했지만 DbController이라는 별개의 함수를 작성했습니다.이 함수는 Angular를 인식하지 못합니다. 등록 된 컨트롤러로 삭제 기능을 이동하십시오. 이와 같이 :

crudApp.controller("DbController", ['$scope', '$http', function ($scope, $http) { 
        // Sending request to EmpDetails.php files 
        getInfo(); 
        function getInfo() { 
         $http.post('select.php').success(function (data) { 
          // Stored the returned data into scope 

          $scope.details = data; 

          console.log(data); 
         }); 
        } 

        $scope.deleteInfo = function() { 
        alert("hello"); 
        } 
       } 
+0

고마워요 그 작품은 –

+0

오신 것을 환영합니다 ... – AranS

관련 문제