javascript - AngularJS - TypeError: string is not a function -
I have an AngularJS controller that passes the form data from the spring controller, the Spring Controller gives a JSP page because its response is. This works fine when I call the spring controller directly with the GET method. I'm getting look: - < / P> Spring controller: - Arora in the console: - Anyone Can you show me a way to solve this? I think the problem is here ... Instead, pass the function as a callback ... typeError: when I call the controller in the
ng-click submit button, then the string in the Chrome console is not a function
& lt; Form name = "empForm" ng-controller = "insertEmpCtrl" & gt; Name: & lt; Input type = "text" class = "form-control" name = "fname" ng-model = "formData.fname" /> & Lt; / Form & gt; & Lt; Input type = "submit" value = "save" ng-click = "insertEmp ()" /> & Lt; / Form & gt; AngularJS controller:
empApp.controller ('insertEmpCtrl', function ($ radius, $ http) {$ scope.insertEmp = function () {$ Scope.formData = {}; $ http Post ("http: // localhost: 8080/idia/updem", $ scope.formData, {with credentials: true, header: {'content-type': undefined}, success ($ scope.message = "employee added "Error") (console.log ("error"));};})
@RequestMapping (value = "/ Addemp", method = {RequestMethod.POST, RequestMethod.GET}) Public string AddEmployee (Modelmap model) {string fname = model.get ("fname"). ToString (); string lname = model.get ("ln Ame "). ToString (); String contact no = model.get (" contacton "). ToString (); EmployeeManager.insertEmployee (fname, lname, contactno); Return" Hello ";}
type error: string is not a function https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min. Js: 70 +1515 at m.promise.then.u (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:97: 280) at m.promise.then .u (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:97,280) https: //ajax.googleapis at .com / ajax / libs / angularjs / 1.2 16 / angular mnjs: 98: 417 a. $ Get.h. $ Eval (https://ajax.googleapis.com/ajax/libs/angularjs/1.2) .16 / Angelor.MMJs: 108: 482). Get the dollars. $ Digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js: 106: 62). $ Get.h. $ Applicable (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:10 9: 287) at f (https: //ajax.googleapis.com/ajax/libs /angularjs/1.2.16/angular.min.js:71x447) at F (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16) /angular.min.js:75-408) XMLHttpRequest On .x.onreadystatechange (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:76:457)
. Success ($ scope.message = "employee added")
$ scope.message has been assigned "employee added" (a string) And then
success () has been passed as a callback function. When the Ajax call is completed, it is being implemented as a function, thus error arises.
$ http.post ("Http: // localhost: 8080 / Ideoidon / Adepp") $ Scope.formData, {withCredentials: true, header: {'content-type': undefined}, transformRequest: angular.identity}). Success (work () {$ scope.message = "employee added";}) error (function () {console.log ("error");});
Comments
Post a Comment