Reputation: 2105
I have a file structure like this :
/root
--/app
----app.ts
--/components
----/banner
------banner.ts
------banner.css
--index.html
I have import banner.ts inside app.ts like this
import {Banner} from '../components/banner/banner';
In banner.ts, I want to get the banner.css file so I write this:
import {Component} from 'angular2/core';
@Component({
selector: 'banner',
templateUrl: '../components/banner/banner.html',
styleUrls: ['../components/banner/banner.css']
})
This works, but when I change to this, it failed:
styleUrls: ['./banner.css']
I also try styleUrls: ['banner.css']
, failed
Based on my understanding, the './' means in the same directory, but why I get an 404 error?
I am using the most updated Angular2
Upvotes: 0
Views: 1680
Reputation: 891
Hi I am happy to see this:
In visual studio 2015
Hope it helps
Upvotes: 1
Reputation: 2000
Yes, Only a proper relative file path will be recognized by Angular2 currently. The Path should actually start from the root like below to be safe, Again we are setting the guidelines from what is working and not working with the beta version, I am sure this is bound to change in the future. But for now, for beta0 the below code is the norm for referencing supplement files for the component.
import {Component} from 'angular2/core';
@Component({
selector: 'banner',
templateUrl: './app/components/banner/banner.html',
styleUrls: ['./app/components/banner/banner.css']
})
Checkout other large example as well, they all use this pattern. A component inside a large Angular2 Sample
Upvotes: 1