The recent week to do a page, the process of production encountered a variety of problems, from which I can see the JS Foundation is not solid enough, ANGULARJS is just the level of entry, now will be the production process encountered in a summary, convenient for later review.
One, string type and JSON convert each other
1, use NG to convert
Angularjs with Fromjson and Tojson two methods for working with conversions between JSON and string types
var json = ' {' name ': ' liSi ', ' Password ': ' 321 '} '; String Type
var jsonarr = ' [{' name ': ' Zhangsan ', ' password ': ' 123 '},{' name ': ' liSi ', ' Password ': ' 321 '}] '; String Type
When you see such data, to get the value of name, password, the first thought must be Json.name, Json.password, Jsonarr[0].name, Jsonarr[1].name, But the actual print will be undefined
It turns out that JSON and Jsonarr are string types, not JSON objects, and you can only convert string types to JSON objects if you want to use the method above to get the values.
The output results are as follows:
Conversely, Angularjs.tojson is converting a JSON object to a string type:
2, using JS to convert, please see the article using JS to convert between string and JSON method
Using ANGULARJS to make a page summary of knowledge Points: String type and JSON convert each other