ionic-cli icon indicating copy to clipboard operation
ionic-cli copied to clipboard

relative template and style urls in ionic2

Open jgw96 opened this issue 10 years ago • 30 comments

From @michaelknoch on June 15, 2016 14:48

is there a possibility to use relative template and style urls for ionic2 components when using browserify bundle?

I am running an angular2 web app using CommonJS and module.id in my components. The plan is to reuse these ng2 components in my ionic application, but i was not able to fix the relative/absolute path problem for now.

Anny suggestions?

Copied from original issue: driftyco/ionic#6922

jgw96 avatar Jul 21 '16 19:07 jgw96

@aaronbroad Agreed. The encapsulation is one of the reasons I like Angular2 so much. Not sure why the ionic team decided against it. @jgw96 any updates on the styleUrls?

DrewLandgrave avatar Sep 29 '16 22:09 DrewLandgrave

Seems like the SCSS rules must match the Component selector. That means you need to declare a selector on each page component, just for this purpose. You wouldn't need a selector otherwise since the components are inserted into the <ion-nav> by the NavController.

Hence this change in ionic2-starter-tabs I guess.

mirkonasato avatar Sep 30 '16 11:09 mirkonasato

I've run into that same issue today. Any update on this ? Can't I use angular2 styleUrls ? Do I have to import all scss file manually into the app.scss file instead ? (that would be a pain)

graphicsxp avatar Oct 17 '16 12:10 graphicsxp

Any update on this? I really would like to use the styleUrls the right way!

allaanz avatar Nov 14 '16 19:11 allaanz

I agree. Instead of grabbing all the (S)CSS files and generating one big file, why not use the features Angular 2 has? It works great and it's also clear for everyone switching over from vanilla Angular 2 to Ionic 2. At first I was like "What!? Why can't I use the styleUrls property" and "What!? I didn't reference the stylesheet but the styles are still applied".

I haven't tested this, but what happens if I happen to have 2 components with the same selector but in different feature modules? Let's assume the selector is foo-bar. In both SCSS files I use the foo-bar selector. You will probably end up with a collision where the one is overwriting the other. That's the beauty of view encapsulation, which you get with the styleUrls property.

So yes, I hope this issue gets a little more attention.

SamVerschueren avatar Jan 25 '17 09:01 SamVerschueren

@Component({ selector: 'page-register', templateUrl: 'list.html','page.html' })

In above if I have 3 html files so one will go as selector in above but how do I write other two files in templateUrl

nikhildhar123 avatar May 02 '17 09:05 nikhildhar123

Why do won't to do this?

I think it is better to have one Component so one selector per template.

Which are your use case you wan't to have more templates per component? I never used this and I'm also not sure if this is possible, I don't think so!

mburger81 avatar May 02 '17 09:05 mburger81

@nikhildhar123 That doesn't work. You can only set one template url per component. If you want multiple templates, use one component per template. This has nothing to do with this feature request.

SamVerschueren avatar May 02 '17 10:05 SamVerschueren

This issue has been automatically closed because it had the v2 label. Please install the new CLI v3 (npm install -g ionic@latest). See CHANGELOG.md#Upgrading from CLI v2 for details.

If this issue is still a problem in CLI v3, please create a new issue. Thank you!

imhoffd avatar Jul 28 '17 22:07 imhoffd

Does it solve the problem?

MaciejCaputa avatar Dec 05 '17 22:12 MaciejCaputa