dpsthree
dpsthree

Reputation: 2285

Why are my Angular, absolute path, URL's not compiling properly with Closure Compiler?

Take the following example directive:

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

This runs through the Closure Compiler without error. However, when loading the app I am greeted with a 404 as it tries to load the full /my/absolute/path.tmplt.html path. Removing the leading '/' resolves the problem. This is also a problem for ng-include(src="'/my/url'"), ng-controller="myCtrl") located in the HTML files and I suspect anywhere you could reference a url.

So why do absolute paths fail while relative ones work just fine?

Upvotes: 0

Views: 784

Answers (1)

basarat
basarat

Reputation: 276105

You have an invalid path specified. If you current page is asdf.com/boo/yourpage try going to asdf.com/my/absolute/path.tmplt.html You should see a 404.

This is not really related to angular Or google closure and is related to your folder structure + your server configuration.

Upvotes: 2

Related Questions