为什么我的Angular,绝对路径,URL没有使用Closure Compiler正确编译?

时间:2013-08-12 21:51:28

标签: angularjs google-closure-compiler

采用以下示例指令:

.directive("myDirective", function() {
    return {
        restrict: "A",
        templateUrl: "/my/absolute/path.tmplt.html",
        controller: ...Do Controller Stuff...
    }
});

这会在没有错误的情况下贯穿Closure Compiler。但是,在加载应用程序时,我遇到了404,因为它尝试加载完整的/my/absolute/path.tmplt.html路径。删除前导'/'可以解决问题。这也是一个问题 ng-include(src="'/my/url'"), ng-controller="myCtrl")位于HTML文件中,我怀疑您可以在任何地方引用网址。

那么为什么绝对路径失败而相对的路径工作正常呢?

1 个答案:

答案 0 :(得分:2)

您指定的路径无效。如果您当前页面为asdf.com/boo/yourpage,请尝试转到asdf.com/my/absolute/path.tmplt.html您应该看到404.

这与angular或Google封闭无关,与您的文件夹结构+服务器配置有关。