Ich bin sehr neu in Angular JS und implementieren eine Funktionalität zum Speichern von Daten. Hier ist mein Code- script.jsFehler in Angular JS erhalten
function EmpCtrl($scope) {
$scope.save = function() {
$.ajax({
type: "POST",
url: "EmpWebService.asmx/SaveEmployee",
data: "{'name':'" + $scope.EmpName + "','age':'" + $scope.EmpAge + "','city':'" + $scope.EmpCity + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg.d);
},
error: function (msg) {
alert(msg.d);
}
});
};
}
Employee.aspx
<html xmlns="http://www.w3.org/1999/xhtml" ng-app>
<head runat="server">
<title></title>
<script src="Scripts/angular.js"></script>
<script src="Scripts/jquery-1.8.3.min.js"></script>
<script src="Script.js"></script>
</head>
<body>
<form id="form1" ng-controller="EmpCtrl" ng-submit="save()">
<div style="font-family: Verdana; font-size: 12px; margin-left: 450px;">
<table>
<tr>
<td style="text-align: right;"> Name :
</td>
<td>
<input type="text" id="txtEmpName" ng-model="EmpName" />
</td>
</tr>
//rest code
Nach Drücken der Taste F12 ich immer bin nach fehler- Argument 'EmpCtrl' ist keine Funktion, wurde nicht definiert
duplicate: http: //stackoverflow.com/questions/25679182/angular-1-3-cant-find-the-controller-function/25679323 –
In ng-Controller Name des Controllers keine Funktionsprüfung. –
** Verwenden Sie jQuery '$ .ajax' nicht, wenn Sie eckige Apps implementieren. Verwenden Sie stattdessen das eingebaute '$ http'. – Kyle