[英]bootstrap AngularJS service with asynchronous data using angularAMD
我有一個與這個問題中暴露的問題非常相似的問題( AngularJS:使用異步數據初始化服務 )。 我的不同之處在於,我使用angularAMD異步加載腳本,而我無法在以下app.config中使用上述方法:
define(['angularAMD'], function (angularAMD) {
var app = angular.module('app', []);
app.config(['$routeProvider', function ($routeProvider) {
// some code here
}]);
app.run(['srvRules', function (srvRules) {
srvRules.getRules().then(function (result) {
// I need to bootstrap only after I get the rules from the server
});
}]);
return angularAMD.bootstrap(app);
});
編輯1
這是我試圖完成的方法: https : //stackoverflow.com/a/21189057/2407203
編輯2
添加更多信息:我有一個webapi作為后端,它是一個遺留系統,可提供設置應用程序所需的各種業務規則。 目前提供的主要信息是:
確實沒有簡單或優雅的出路。 我最終做了以下工作:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.