Solutions to some problems encountered by angularJS and angularjs
1. For angularJS $ http. post request, SpringMVC does not receive the parameter value in the background.
The problem is generally: 400 Required String parameter 'rpassword' is not present or other 400 errors
Solution 1: Modify the source code http://my.oschina.net/buwei/blog/191640 (can be detailed to understand the reason the request is not received)
Solution 2: the source code is always difficult to modify. You can use this method to modify the headers and transformRequest parameters of config.
(1) create a globalTransformRequest function
var app = angular.module('myApp');app.config(function ($httpProvider) { $httpProvider.defaults.transformRequest = function(data){ if (data === undefined) { return data; } return $.param(data); }});
Then create a globalContent-Type header
$httpProvider.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
(2) create a localTransformRequest
var transform = function(data){ return $.param(data); } $http.post("/foo/bar", requestData, { headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}, transformRequest: transform }).success(function(responseData) { //do stuff with response });
Reference URLAngularJS-Any way for $ http. post to send request parameters instead of JSON?
2.Scope. $ apply usage
The problem is generally: the two-way Data Binding fails, that is, the $ scope is clearly given to the controller. xxx records cannot be displayed on the page. However, if you click the submit button in the input box or form, the xxx data is displayed.
Solution: add$ Scope. $ apply ()
For example
$ Scope. $ apply (function() {$ Scope. xxx = "your assigned value ";
});
Cause
Generally, you do not need to manually add this code, because angularJS calls this code as needed to achieve the effect of bidirectional data binding.
However, if you reference an external plug-in or others, you can create or update it in the callback function.$ Scope. xxxBecause the external plug-in itself is out of the angularJS scope, the two-way data binding is ineffective here. You can only manually add $ scope. $ apply () to notify the page to obtain data.
3. Because it is a newbie, it comes step by step.
Select echo of AngularJs
I don't know what your aa and some data formats are like. The following is a selected example:
<! DOCTYPE html>
According to AngularJS, I need an example of adding, deleting, querying, modifying, and providing high score guidance.
You have sent a friend to add