小编jod*_*ate的帖子

angular.forEach和objects

问题:

我正在做(我认为但可能不是)一个简单angular.forEach的数组,然后使用$resource基于返回的每个值进行调用.每次调用的结果都是一个对象,正如我所期待的那样.但是,我无法以angular.forEach文档演示的方式和谐地连接这些对象.

但首先,一些代码可以工作,然后查看失败的代码.

作品:

var uniqueIds = {};
angular.forEach(object, function(key, value){
    this.push(key.uniqueIds);
}, uniqueIds);
console.log(uniqueIds)
// uniqueIds equals the expected array
Run Code Online (Sandbox Code Playgroud)

失败

事情变得棘手.现在,在下一个示例中,内部angular.forEach是一个$resource调用.

angular.forEach(array, function(index){
    Resource.query({id:index}, function(result){
        console.log(result)
        // returns the expected object, 
        // but, as expected, I can't access the object outside the async call
    });
    console.log(result);
    // result is undefined
 });
Run Code Online (Sandbox Code Playgroud)

鉴于异步,似乎一个承诺可以解决问题.但它没有 - 我真的还在异步电话里面.也没有分配result$scope工作.简而言之,我似乎无法获得超出的价值Resource.query.

我需要做什么?

我需要每个$resource调用的返回对象添加到一个对象(使用angular.extend?我已经尝试过),就像angular.forEach创建数组一样.我尝试了很多不同的方法,大多数都基于这里提出的一般异步问题的答案,但到目前为止无济于事.我很肯定这是一个从$resource …

javascript foreach asynchronous object angularjs

13
推荐指数
1
解决办法
7万
查看次数

审查委员会,审查后和删除的文件

谷歌搜索和阅读评论委员会的文件(和窃听同事)到目前为止还没有解决这个问题.

我正在使用Review Board(1.5)进行代码审查.在进行命令行后审查时,审核委员会在删除文件时不喜欢它(svn del,即).

换句话说,例如r1有foo.js但是r3在重组和清理不再使用的文件时删除了foo.js svn.

进行后期审核时,错误消息为:

server$ post-review --revision-range=r1:r3 --submit-as="jody"
Failed to execute command: ['svn', 'info', 'js/app.conf.js']
['js/foo.js:  (Not a versioned resource)\n', '\n', 'svn: A problem occurred; see other errors for details\n']
Run Code Online (Sandbox Code Playgroud)

如何在不需要的文件的情况下进行svn del,但在没有错误的情况下继续进行后期审核?

review-board

8
推荐指数
1
解决办法
1276
查看次数