2017-05-23 33 views
0

我想將dashboardApi的值從http://devdashboard.company.com/'更改爲../api(相對路徑爲一級文件夾的相對路徑),我嘗試了../api,但不起作用,該如何解決?如何更改angualar.module常量配置字段?

'use strict'; 

angular.module('configuration', []) 
    .constant('config', { 
     dashboardApi : 'http://devdashboard.company.com/', 
     authApi: 'http://urlink.company.com/', 
     debug: false, 
     firstName: '', 
     lastName: '', 
     userid: '', 
     employeeid: '', 
     qGroups: [""], 
     role : '', 
    }); 

回答

0

不管你想要去改變它,你可以注入config依賴內部所需的主角度模塊component

//make sure configuration module have been injected in main app module. 
angular.module('app', ['configuration']); 

//here I took an example of config block of your application. 
//because generally such setting should be set at configuration time of app. 
//the same inject you can do it other component as well, like controller, directive, factory, etc. 
angular.module('app').config(['config', function(config){ 
    config.dashboardApi = '../api.' 
})