relative template and style urls in ionic2
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
@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?
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.
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)
Any update on this? I really would like to use the styleUrls the right way!
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.
@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
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!
@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.
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!
Does it solve the problem?