javascript - 使用 AngularJS 中的点读取 JSON 变量

标签 javascript angularjs json sequelize.js

我正在使用 Sequelize,经过多次尝试进行内部连接后,我取得了不错的结果:

{
    "success": false,
    "message": "Query not successful, the result was empty",
    "data": {
        "codWO": "1016285246",
        "codType": "01",
        "origin": "1016285246--origin",
        "solution": "1016285246--solution",
        "consecuence": "1016285246--consecuence",
        "actions": "1016285246--actions",
        "hours_stopped": 20.5,
        "failureState": "1016285246--failureState",
        "failureEquipment": "1016285246--failureEquipment",
        "failureEffect": "1016285246--failureEffect",
        "failureCause": "1016285246--failureCause",
        "wo_cor_type.name": "Emergency Repair",
        "wo_cor_type.description": "Urgent repairs such as a broken device that avoid running the test.",
        "wo_cor_type.codType": "01"
    }
}

我可以读取除最后一棵树之外的所有变量,因为它们有点。

我怎样才能读取这种变量?
    vm.woCorrective = data.data;
    console.log(data.success);
    console.log(vm.woCorrective);
    console.log(vm.woCorrective.codWO);
    console.log(vm.woCorrective.solution);
    console.log(vm.woCorrective.failureCause);
    // console.log(vm.woCorrective.[('wo_cor_type.name')]);

最佳答案

试试这个:

console.log(vm.woCorrective["wo_cor_type.name"]);
console.log(vm.woCorrective["wo_cor_type.description"]);
console.log(vm.woCorrective["wo_cor_type.codType"]);

关于javascript - 使用 AngularJS 中的点读取 JSON 变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49354039/

相关文章:

javascript - 将 .load html 文件的内容存储在变量中

javascript对象数组没有改变

jquery - 有任何用于处理 cookie 法律合规性的 Angular 指令吗?

AngularJs $scope.$apply 没有按预期工作

javascript - php 解码 json 数组

javascript - 处理嵌套 JSON 数据时避免嵌套 every 循环

json - 为没有字段的 Java 枚举创建读/写

javascript - 如何从多个 kaminari 页面中选择全部

javascript - 客户端需要 Cookies 值且 Httponly 属性为 true

javascript - 单击下拉菜单显示叠加层