Unable to load assets without using require() #1363

Closed
opened 2025-08-09 17:19:52 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @RobCannon on 9/25/2016

The template uses require() to load assets from a source .html or .css file. For example:

@Component({
    selector: 'nav-menu',
    template: require('./navmenu.component.html'),
    styles: [require('./navmenu.component.css')]
})

But Angular also allows you to load those assets with a url. In fact, that is the default mechanism when you create an app with angular-cli. It would look like this:

@Component({
    selector: 'nav-menu',
    templateUrl: './navmenu.component.html',
    stylesUrl: ['./navmenu.component.css']
})

But that does not work with this template. It should work because a lot of Angular examples use that and it will lead to a lot of confusion. Also, it makes it difficult to port an app built with angular-cli to use this framework.

*Originally created by @RobCannon on 9/25/2016* The template uses require() to load assets from a source .html or .css file. For example: ``` @Component({ selector: 'nav-menu', template: require('./navmenu.component.html'), styles: [require('./navmenu.component.css')] }) ``` But Angular also allows you to load those assets with a url. In fact, that is the default mechanism when you create an app with angular-cli. It would look like this: ``` @Component({ selector: 'nav-menu', templateUrl: './navmenu.component.html', stylesUrl: ['./navmenu.component.css'] }) ``` But that does not work with this template. It should work because a lot of Angular examples use that and it will lead to a lot of confusion. Also, it makes it difficult to port an app built with angular-cli to use this framework.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#1363
No description provided.