Original address:http://www.jmingzi.cn/?post=13
Beginner Anjularjs two days, while learning while writing the message board, only a level of reply nested. Demo Address
Here is a summary of the learning process and notes. In addition, look at This article will also have the harvest.
I think ANGULARJS is the implementation of PHP a lot of functions and methods, in addition to not directly manipulate the database, he has a lot of plug-ins can provide use, very powerful.
The problem I encountered:
1. When submitting to PHP using the $http.post () method, the PHP receive statement is this:
1 $shuju = file_get_contents(' Php://input ', true);
Search a lot, did not give a reasonable explanation, only know that it is possible. We usually use forms to submit past data to be received by $_post, which is the result of the different header submissions.
We used ANGULARJS to submit the past is JSON format data, header is Content-type:application/json
And the form form is submitted in the past: Multipart/form-data
The solution of course there are 2, one is that the above method can be received,$_POST = json_decode(file_get_contents(‘php://input‘),true);
Another is to modify the header, $httpProvider.defaults.headers.put[‘Content-Type‘] =
‘application/x-www-form-urlencoded‘;
View Articles
In addition, to do the submission of the form, look at this article will also help;
2, the 2nd problem encountered is the routing parameters
Since I do not use the Ui-router plugin, the native ng-router is not able to route nesting, but at present I do not need to embed a routine, only need to pass a simple number of parameters. In fact, it is not difficult, the following wording:
. When ('/replay/:cid/:name ', {templateurl: "tpl/form.html", Controller: "Formctrl"})
Receive in the controller
Liuyan.controller (' Formctrl ', function ($scope, $http, $routeParams) {$routeParams. CID;}
There's also a lot of reference to the official API documentation, as well as viewing the UI that has been implemented
The tutorial URL also has a: http://www.yiibai.com/angularjs/angularjs_custom_directives.html
There is also an article about JSON: http://www.ruanyifeng.com/blog/2009/05/data_types_and_json.html
ANGULARJS Study notes (make a message board)