即使我已經做好正確的程序,我也無法獲得刪除功能的警報,所以請幫助我一樣。感謝您提前解決我的問題 我無法獲得警報對於刪除功能,即使我做了正確的程序,請幫助我的same.Thanks提前解決我的問題刪除功能不能在角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>
您是否設法使用'employeecontroller'?它看起來好像沒有註冊到你的應用程序。沒有錯誤? – AranS
無需重複自己... –