In my Angular-cli RC5 project I am trying to create charts.
- Created a new component as "chart"
- Created a directive as "line-graph.directive.ts"
Folder structure.
app.module.ts
import {NgModule, enableProdMode} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {AppComponent} from './app.component';
import {ChartComponent} from './chart/chart.component';
import {LineGraphDirective} from './chart/line-graph.directive';
@NgModule({
declarations: [AppComponent, ChartComponent, LineGraphDirective],
providers: [],
imports: [],
bootstrap: [AppComponent],
})
export class AppModule {
}
chart.component.html
<p>
chart works!
</p>
Then, I added following inside the app.component.html as below.
<app-chart></app-chart>
Then "chart works!" line should display when I run the application.
But it doesn't.
chart.component.ts
import {Component} from '@angular/core';
@Component({
moduleId: module.id,
selector: 'app-chart',
templateUrl: 'chart.component.html',
styleUrls: ['chart.component.css'],
directives: []
})
export class ChartComponent {
constructor() {}
}
line-graph.directive.ts
import {Directive, ElementRef} from '@angular/core';
@Directive({
selector: 'line-graph'
})
export class LineGraphDirective {
constructor() {}
}
app.component.ts
import {Component} from '@angular/core';
@Component({
moduleId: module.id,
selector: 'app-root',
templateUrl: 'app.component.html',
styleUrls: ['app.component.css']
})
export class AppComponent {
title = 'app works!';
}
Any suggestions of what i have done wrong with my code.
Thank You

If you look in your browser's network requests, I bet you will find some
404 not founderrors whenAngulartries to load the chart component.Your import paths are not correct. Change
With the right paths. The folder structure is difficult for me to make out from your image (small indentation) but your current import would only work if the
chartdirectory was in the same folder asAppModule