如何从下面的范围变量中读取scriptduration?

时间:2016-06-23 05:43:50

标签: jquery angularjs json

       {
        "errorMessage": "",
        "instructionIdWithInScript": 1,
        "screenShotFilePath": "/204/1574/screenshots/112186/1.jpg",
        "scriptDuration": "00:01:45",
        "automationDriverName": "Selenium-WebDriver",
        "screenShotFileSize": "277.830078125",
        "screenShotStatus": 28304,
        "value": "",
        "command": "open",
        "scenarioOrder": 1,
        "instructionResult": "Pass",
        "scenarioResult": "Pass",
        "scriptName": "01_copy of SearchBookProduct_WIP",
        "scriptOrder": 1,
        "scriptResult": "Pass",
        "scriptRowCount": 0,
        "scenarioDuration": "00:09:29",
        "scriptDisplayOrder": 1,
        "scenarioName": "Amazon",
        "dataFileName": null,
        "target": "http://www.amazon.com/http://www.amazon.com/http://www.amazon.com/http://ww…zon.com/http://www.amazon.com/http://www.amazon.com/http://www.amazon.com/",
        "globalInstructionSequesnce": 1,
        "scriptIterationOrder": 0,
        "instructionDuration": "00:00:15",
        "dataFilterDesc": null,
        "selected": false,
        "downloadSelect": false
    }

我在写$scope.metaInfo.scriptDuration时遇到错误。 无法读取属性" scriptDuration"未定义。

我用正确的信息编辑了我的问题..

1 个答案:

答案 0 :(得分:0)

如果$scope.metaInfo是数组,则可以通过这种方式访问​​,在我的情况下是正确的。

$scope.metaInfo["scriptDuration"]

如果它的对象那么

$scope.metaInfo[0].scriptDuration

问候。