1. Angularjs $http.post request, SPRINGMVC background cannot receive parameter value solution
The problem is generally:Required String parameter ' Rpassword ' is not present or other 400 error
Workaround One: Modify the source http://my.oschina.net/buwei/blog/191640 (you can learn more about why the request is not received)
Solution Two: Feel modified source code is always bad, you can use this method, modify the submission parameter config headers and transformrequest
(1) Create a global transformrequest function
var app = Angular.module (' myApp '); app. Config (function ($httpProvider) { function (data) { if (data = = = undefined ) {return data; } return $.param (data); }});
Then for each method or create a global Content-type header
$httpProvider. defaults.headers.post[' content-type '] = ' application/x-www-form-urlencoded; Charset=utf-8 ';
(2) Create a local transformrequest for each required method
var function (data) { return $.param (data); } $http. Post ("/foo/bar", RequestData, { ' content-type ': ' application/x-www-form-urlencoded; Charset=utf-8 '}, transformrequest:transform }). Success (function( ResponseData) { //dostuff with response });
Reference URL Angularjs-any $http. Post to send request parameters instead of JSON?
2. use of scope. $apply
The general problem is: Data two-way binding invalidation, is clearly in the controller inside give $scope.xxx assignment, on the page xxx leng display, but click on the input box or form form of the submit button, XXX data information shows, is not good pit ah.
Workaround: Add $scope. $apply ()
For example
$scope. $apply (function() { = "The value you have assigned";
});
Reason
In general, we do not need to add this code manually, because the ANGULARJS itself is called when needed in order to achieve the effect we see the data two-way binding.
But if you refer to an external plug-in or other, create or update $scope in the callback function . XXX data, because the external plug-in itself has been out of the scope of ANGULARJS, so data bidirectional binding here is not effective, can only manually add $scope. $apply () to inform the page to get the data.
3. Because it is a novice, step-by-step to
Solutions to some of the problems encountered with Angularjs