【问题标题】:what is the "f" mean in angular promise?角度承诺中的“f”是什么意思?
【发布时间】:2013-12-30 02:34:45
【问题描述】:

最近我一直在学习 Angular 以开发一个新项目。 当我使用$q$resource实现ajax请求时

这是有数据时的响应:

[{"number":"132412341234","type":"5","createTime":1388369479626,"updateTime":1388369479626,"kind":"devices#get","id":"52c0d6470cf2393bb3df6371"}]

这是无数据响应的响应:

[{"request":"persons/529c6a970cf2ce4b156d0f3e/devices","status":404,"error":"can't find persons records"}]

但是,当我返回控制器以承诺获取这些数据时:

var devices=DeviceResource.query({personId:1234});

响应设备变为:

[$promise: Object, $resolved: false]
    0: f
        $$hashKey: "00M"
        error: "can't find persons records"
        request:"persons/529c6a970cf2ce4b156d0f3e/devices"
        status: 404
        __proto__: f
    $promise: Object
    $resolved: true
    length: 1
    __proto__: Array[0]

数组[0]的proto是“f”

“f”是什么意思?我在哪里可以获得这些文件?

在 angular $q 文档中似乎只是一些承诺内容。

有人可以帮我吗? 非常感谢...

【问题讨论】:

    标签: javascript angularjs promise


    【解决方案1】:

    我假设您使用的是缩小版。尝试使用生产版本来获得更好的跟踪,例如:

    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.js"></script>
    

    【讨论】:

    • 我猜你的意思是链接到 not 缩小版? ajax.googleapis.com/ajax/libs/angularjs/1.2.6/angular.js
    • 感谢您的建议,但在切换生产版本后,我仍然无法获得任何我想要的东西。如何在 chrome 调试中跟踪 proto
    • 当我在范围变量中跟踪它时,我可以看到一些变量: [code](devices: Array[0] $promise: Object catch: function (callback) { finally: function (callback ) { then: function (callback, errback, progressback) { proto: Object $resolved: false length: 0 proto: Array[0])
    • 我的理解是 $resource 用返回的内容覆盖了 promise 的字段,promise 被移到了 $promise 中。所以原型大概是指您的查询返回的内容。如果您想查看 Promise,也许您应该在发出请求后立即在代码中使用 console.log() 或其他内容。
    • 也许你能想出一个plunkr?看起来它没有解决。
    猜你喜欢
    • 1970-01-01
    • 2018-11-24
    • 2020-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-21
    相关资源
    最近更新 更多