5
我有一個配置對象中的這兩個布爾變量,我將其傳遞給角度應用程序的一個常量。覆蓋量角器測試中的常量
這些布爾值都在頁面解析時被檢查。如果兩者都是真的,它會保留在頁面中,如果其中一個是真的,它會將用戶彈回到指定的頁面。
見下
angular
.module('ecardGeneratorPrototype')
.constant('config',
{
"enable-file-upload": true,
"enable-webcam": true
的代碼,然後我下決心功能檢查這些:
.when('/home', {
templateUrl: 'app/home/home.html',
controller: 'HomeController',
controllerAs: 'home',
resolve : {
choice: ['$route', '$window', 'config', function ($route, $window, config) {
if (config["enable-file-upload"] && config["enable-webcam"]){
//return
return;
}
else
{
if (config["enable-file-upload"]){
//go to the file upload page
//$log("display the file upload page");
$window.location.href = '#/file-upload';
}
else if (config["enable-webcam"]){
//$log("display the webcam page");
$window.location.href = '#/webcam';
}
}
return;
}]
}
})
我的問題是,我可以覆蓋這些常量,所以我可以測試的網頁被正確重定向中我的量角器測試?