嗨我有一个像我的控制器中的跟随代码
myClientApp.controller('ListCtrl', function ($scope,$http,$cookieStore,$location, $routeParams) {
var data = {
"menus": {
"view": true,
"add": true,
"update": true,
"delete": true
},
"linkInfo": {
"labelColumn": "codeName",
"linkColumn": "lookupKey",
"urlInfo": "reference"
},
"resultList": [
"{\"lookupKey\":2,\"clientKey\":1,\"codeName\":\"Application.AppType\",\"codeValue\":\"ApplicationType2\",\"codeDesc\":\"##\",\"updatedBy\":null,\"internalCodeName\":\"Application.AppType\"}",
"{\"lookupKey\":3,\"clientKey\":1,\"codeName\":\"Application.Class\",\"codeValue\":\"Tier 1\",\"codeDesc\":\"Critical Application requiring immediate response in case of a disruption of Service\",\"updatedBy\":null,\"internalCodeName\":\"Application.Class\"}"
]
};
$scope.result = angular.fromJson(data.resultList);
alert($scope.result[0].codeName);
});
Run Code Online (Sandbox Code Playgroud)
它给了我不确定的.为什么?
min*_*gos 13
因为resultList是一个JSON字符串数组,而不是一个JSON字符串; 您需要指定要解码的键:
$scope.result = [
angular.fromJson(data.resultList[0]),
angular.fromJson(data.resultList[1])
];
alert($scope.result[0].codeName);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
43555 次 |
| 最近记录: |