Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Injecting chart containers #111

Closed
NastyLucas opened this issue Nov 13, 2015 · 3 comments
Closed

Injecting chart containers #111

NastyLucas opened this issue Nov 13, 2015 · 3 comments

Comments

@NastyLucas
Copy link

Hi I'm having a little trouble picking up a directive in angular: when I try to inject it using this function, does it require me to already have the angular chart tag on the page or is there a way around this to inject the data in?

angular.element( document.getElementById('chart-container-inject') ) .prepend( $compile( '<angular-chart options="options" style="height: 500px"></angular-chart>' )( $scope ) );

Lucas

@maxklenk
Copy link
Member

Hey @NastyLucas,

perhaps you can explain a little bit more what you want to archive by injecting the chart this way. What worked for me was the following setup:

$scope.options = someOptions;
$compile(
  angular
    .element( document.getElementById('chart-container-inject'))
    .prepend('<angular-chart options="options" style="height: 500px"></angular-chart>')
)( $scope );

@NastyLucas
Copy link
Author

Oh wow thank you very much I hadn't thought of that approach, I'd been tearing my hair out trying to get that to work properly so thanks for the reply!

@maxklenk
Copy link
Member

No problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants