1

I am generating a series of <circle ng-if='n'> someScopeFunction()' \> with d3.js

How can I get Angular to notice and work on these new elements and ng-ifs?

And how can I get it to do so with angular variables, e.g. <circle some-attr='{{i - 2}}' />

yellow-saint
  • 884
  • 2
  • 13
  • 37

3 Answers3

1

You have to wrap them with a scope. Maybe a Controller. I also suggests you to not use ng-if if you just want to hide/show them, since its expensive. You better use ng-show / ng-hide

Or maybe look for a solution like angular-nvd3

Avraam Mavridis
  • 8,698
  • 19
  • 79
  • 133
1

You need to use the $compile service as suggested in this answer, though I would recommend using Angular to generate and insert <circle>. I wrote a blog post on D3 + Angular that you might find helpful.

Community
  • 1
  • 1
Neil
  • 2,137
  • 16
  • 24
1

ng-if is a directive, you can use this solution: How do I use angularjs directives in generated d3 html?

The only supposition is that you d3 is already in a directive.

Community
  • 1
  • 1
Raúl Martín
  • 4,471
  • 3
  • 23
  • 42