Angular UI Bootstrap: 未加载模板

Angular UI Bootstrap: not loading templates

我正在使用包含模板的 Angular UI Bootstrap v1.0.3(我选择包含模板,我可以在源代码中看到 *tpls 模块),但是当我打开这样的模式(从 app.run(...) 中):

var type = "sometype";
$uibModal.open({
    templateUrl: "/partials/" + type + "-dialog.html",
});

我收到一个错误:

angular.min.js:93 GET http://.../uib/template/modal/backdrop.html?sessionid=363192 404 (Not Found)(anonymous function) @ angular.min.js:93r @ angular.min.js:89g @ angular.min.js:86(anonymous function) @ angular.min.js:119r.$eval @ angular.min.js:133r.$digest @ angular.min.js:130r.$apply @ angular.min.js:134g @ angular.min.js:87T @ angular.min.js:92w.onload @ angular.min.js:93 angular.min.js:107

Error: [$compile:tpload] http://errors.angularjs.org/1.4.8/$compile/tpload?p0=uib%2Ftemplate%2Fmodal%2Fbackdrop.html&p1=404&p2=Not%20Found at Error (native)

我尝试将模板手动添加到我的代码中,并将以下代码添加到我的 app.js 顶部:

angular.module("template/modal/backdrop.html", []).run(["$templateCache", function($templateCache) {
     $templateCache.put("template/modal/backdrop.html", "<div class=\"modal-backdrop\"></div>");
}]);

还是一样的错误

我发现了错误。

问题是模板是使用我在请求拦截器中添加的查询参数请求的。我向匹配模板 url 前缀的拦截器添加了一个例外,现在它可以工作了。

var noSessionIdUrls = [
    "uib/template",
    "template"
];

app.config(['$httpProvider', function($httpProvider) {
    $httpProvider.interceptors.push( function ($q, $injector, $rootScope) { 
        return {
            request: function(config) {
                for(var i = 0; i < noSessionIdUrls.length; i++) {
                    if(config.url.startsWith(noSessionIdUrls[i])) {
                        console.log("request interceptor: omitting session id");
                        return config;
                    }
                }

                config.url = config.url + '?sessionid=' + window.sessionid;
                return config;
            }
        };
    });
}]);