我想根据作为 HTTP 请求结果的标签设置 module.constant。
以下是我项目中的演示代码;
code in app.js
(function(){
var myApp = angular.module('myApp',['ui.router','ui.bootstrap']);
myApp.contant("API_URL","https://www.helloworld.com/API");
myApp.run(function($rootScope.$http){
some code;
});
})();
我想根据这样的 HTTP 请求的结果配置一个特殊的 Id;
$http.get(API_URL + "/configTag")
.then(function success(response){
var tag = response.data.tag;
if(tag === 0) {
myApp.constant("specialID","111111111");
} else if (tag === 1) {
myApp.constant("specialID","222222222");
} else {
myApp.constant("specialID","333333333");
}
},function error(response){
});
但我是前端和 AngularJS 的新手。我不知道如何意识到这一点?