Atma Atma - 1 year ago 75
Node.js Question

how to reference angular component template from django app

I have the following angular component:

component('phoneList', {
templateUrl: 'phone-list.template.html',
controller: function PhoneListController() {
this.phones = [
name: 'Nexus S',
snippet: 'Fast just got faster with Nexus S.',
age: 1
}, {
name: 'Motorola XOOMâ„¢ with Wi-Fi',
snippet: 'The Next, Next Generation tablet.',
age: 2
}, {
name: 'MOTOROLA XOOMâ„¢',
snippet: 'The Next, Next Generation tablet.',
age: 3

this.orderProp = 'age';

This template:
templateUrl: 'phone-list.template.html',
and the component are inside of my django app.

I have placed the template in:

myapp > templates > myapp > phone-list.template.html

The reference gives me a 404 as well as angular error:

Do I need to create a django url entry?
Do I need use a django url tag in the component?

Answer Source

Templates in the templates folder in Django are available to the template loader only. They are not served and can not be accessed via HTTP directly. But that is what Angular does.

If you need to render the template in Django, make sure you have created a view and an endpoint for it in your

If no rendering is needed and Django can use the template directly serve them like static files.