0

I am trying to implement graph as in this plunker: plunker

Here is the github code: github

But I get an error:

Uncaught (in promise): Unexpected directive value 'undefined' on the View of component.

@Component({
  selector: 'main',
  directives: [nvD3],
  template: 
    <div>
      <nvd3 [options]="options" [data]="data"></nvd3>
    </div>
})
Shalmali Jain
  • 39
  • 1
  • 6

2 Answers2

0

You're trying to use directives on A recent angular2, directives should be configured in @NgModule See this: angular-2-ngmodules

ApriOri
  • 2,618
  • 29
  • 48
0

This is the new way to declare directives using NgModule..

import { nvD3 } from 'ng2-nvd3'

@NgModule({
    ...
    declarations: [
        nvD3
    ],
    ...
})
user781861
  • 89
  • 5
  • 1
    While this code snippet may solve the question, [including an explanation](//meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. Please also try not to crowd your code with explanatory comments, this reduces the readability of both the code and the explanations! – kayess Nov 22 '16 at 10:32