Second for loop will not trigger in my $scope function

試著忘記壹切 提交于 2019-12-13 07:00:04

问题


I have this function that if it works should assign a created div(task tile) to the right user. Check this link for a visual of the application -> http://gyazo.com/539abe727f0c77be39ac85ee46f4c395 As you can see now the task just show randomly on the grid.

This is part of the code from my app.js:

//Link user to a task
    $scope.linkTaskToUser = function() {
        console.log("Logging root scope ", $rootScope);

        for (var i = 0; i < $scope.taskInfo.length; i++) { //Doorlopen van alle taken

            console.log('Logging scope taskInfo -->' , $scope.taskInfo);

            for (var j = 0; j < $rootScope.users.length; j++) { //Doorlopen van alle users
                console.log('fasfsda -->');
                if ($rootScope.users[j].email == $scope.taskInfo[i].email) {
                    console.log('fasfsda1111'); //Vergelijken van emails tussen taken en users
                    $scope.taskInfo[i].top = $rootScope.users[j].offsetTop; //Top waarde van de taak gelijkstellen aan de offset van de user
                }
            }
        }
    }

My problem is now that it will log the 2 first logs but it will not log the third one in the second for loop mean that the second for loop is not being executed.

The idea of this function is that it will loop through all my task and all of my users then it will compare the email of the $rootScope.users to that of the $scope.taskInfo and if there is a match it will set the top value of the $scope.taskInfo equal to that of the $rootScope.users offsetTop, so that the tasks will show on the correct row.

I hope someone can help me out (if you need more code to better understand the situation let me know)

来源:https://stackoverflow.com/questions/31476628/second-for-loop-will-not-trigger-in-my-scope-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!