KthProg
KthProg

Reputation: 2117

TemplateURL not working - request is not sent

The template does not even appear to be being requested. I tried an absolute URL, a relative URL, and even the full-length URL.

The template is not being requested at all, I've checked.

Here is the code:

app.directive('field', function () {
    return {
        restrict: "E",
        templateURL: "http://192.9.200.62:8080/templates/field.html",
        scope : {
            field: "=name",
            ops: "=options"
        }
    };
});

Other URLs I've tried include templates/field.html and /templates/field.html and ../../templates/field.html.

The template works fine if I build it as a string in JS.

Upvotes: 0

Views: 48

Answers (2)

Sunde
Sunde

Reputation: 343

I believe it should be templateUrl, not templateURL.

As far as the correct URL to use, what is the folder structure?

Upvotes: 0

Davin Tryon
Davin Tryon

Reputation: 67316

There are a couple things here. First, the template path is always relative to the root. So, if your templates directory is off the root, then this should work:

/templates/field.html

Second, the property is named templateUrl, the case matters here. So, you need to rename templateURL to templateUrl.

Here is the documentation showing the templateUrl property.

Upvotes: 1

Related Questions