1

修改角我有以下的角度控制器在量角器

.... 
.controller('EndCtrl', ['$scope', '$location', 'Players', function($scope, $location, Players) { 
    console.log('players', Players); 
    $scope.players = Players; 
    $scope.go = function (path) { 
     Players = []; 
     $location.path(path); 
    }; 
}]); 

Players是angular.value()提供商。

我试图运行一个量角器测试,我需要设置Players有什么事情发生的页面

因此之前....

..... 
beforeEach(function(){ 
    browser.get('#/end'); 
    browser.waitForAngular(); 
    browser.executeScript(function(json) { 
     var mod = angular.module('myApp.players'); 
     mod.run(['Players', function(Players){ 
      Players = [json.characters[0], json.characters[1]]; 
      console.log(Players, 'player browser'); 
     }]); 
     console.log('player browser', mod); 
    }, json); 

    }); 

然而,在运行测试似乎在事实之后执行。

我需要的控制器运行之前设定值....

+1

尝试将'browser.waitForAngular();'移动到'mod.run()'命令之后。 –

回答

1

您需要修改PlayersEndCtrl初始化之前。

为什么不在另一个视图上这样做,然后点击一个链接到最后一页(与EndCtrl)。

修改后的Players将被注入。