We have a lot of repeating code and repeating styles when we write our web pages, and we can't knock them out of the way, so it's a manual work.
So when I was in this situation, most of the time I used angular to get JSON, and using angular to import the data from the JSON database into a Web page would allow us to write duplicate code without repeating it.
But some sub-elements are relatively good, but like a drop-down list is more troublesome. Not only is it cumbersome to write JSON files, it's even more complicated to get JSON.
For example, when we're writing a JSON file like this,
"Recruit": [
{"Name": "1", "describe": [
{"Descr": "2"},
{"Descr": "3"},
{"Descr": "4"},
{"Descr": "5"},
{"DESCR": "6"}
],
"Describe1": [
{"DESCR": "11"},
{"DESCR": "22"},
{"DESCR": "33"},
{"DESCR": "44"},
{"Descr": "55"},
{"DESCR": "66"}
]}
]
This JSON file is believed to have been seen, and this JSON is not as simple as what we get when it comes to a single JSON, and we use "subscript" to get the data we want when we get it.
App.controller (' Test ', function ($scope, $http) {
$http. Get ('.. /data/data.json '). Success (function (data) {
$scope. Data = Data.recruit;
$scope. Headernav = $scope. Data[0].name;
$scope. headerNav1 = $scope. Data[1].describe;
$scope. headerNav1 = $scope. DATA[2].DESCRIBE1;
}). Error (function (s) {
alert (s);
})
})
So we can get the data we want and write it to the page.
Using angular to introduce complex JSON files