Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling templates #165

Closed
zoamel opened this issue Oct 25, 2016 · 6 comments
Closed

Handling templates #165

zoamel opened this issue Oct 25, 2016 · 6 comments

Comments

@zoamel
Copy link

zoamel commented Oct 25, 2016

This boilerplate looks really cool, so big thumbs up for it! :) I have one question, how to handle loading templates from a file (I'm not a big fan of inline templates). When I try to do import template from './template.html' I'm getting ts error, that it didn't find any module there.

@elmariofredo
Copy link
Member

Hey I'm glad you like our scaffold 🙂

Think is that we are kind of fans of inline templates a it's because this way you tent to keep components small and simple.

Anyway if you really really don't want to go inline you can either upgrade to typescript 2 and use declare module "*.html" or simply use require("./yourfile.htm").

If you will upgrade to typescript 2 PR is welcome 😉

@blowsie
Copy link

blowsie commented Nov 24, 2016

It would be super neat if the templateUrl syntax worked, as per the angular 2 docs.

@Component({
  moduleId: module.id,
  selector: 'toh-heroes',
  templateUrl: 'heroes.component.html'
})

You mentioned, declare module "*.html", although this does not work, Something is missing from the syntax?

@elmariofredo
Copy link
Member

@blowsie another problem with templateUrl in angular 1 is that it make your component async, quite frankly I'm not sure how does that work in angular 2 as I said we prefer inline 😉

Trick I was mentioning is called wildcard module declarations I'm not sure what is the problem I would check typescript version you are using and related typescript thread microsoft/TypeScript#6615

It should definitely work in our scaffold see 6e91cfd

@aciccarello
Copy link

Has anyone tried using angular2-template-loader with ng-metadata? That would load both templates and style url automatically.

@Hotell
Copy link
Member

Hotell commented Dec 25, 2016

@blowsie

It would be super neat if the templateUrl syntax worked, as per the angular 2 docs.

@component({
moduleId: module.id,
selector: 'toh-heroes',
templateUrl: 'heroes.component.html'
})
You mentioned, declare module "*.html", although this does not work, Something is missing from the syntax?

this works, but with SystemJS :) (module.id is specific for systemJS )
https://github.com/ngParty/ng-metadata/blob/master/playground/app/components/lifecycle/do-check.component.ts#L80

@Hotell
Copy link
Member

Hotell commented Dec 25, 2016

@aciccarello

Has anyone tried using angular2-template-loader with ng-metadata? That would load both templates and style url automatically.

I haven't

@Hotell Hotell closed this as completed Dec 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants