I have Angular2 application in Dart (as here - https://angular.io/docs/dart/latest/quickstart.html) and calling javascript from there (D3.js library)
Problem: css is not loaded for svg circle
app_root.dart:
@Component(
selector: 'root',
templateUrl: 'app_root.html',
styleUrls: const ['app_root.css'],
)
class RootComp {
Future showCircle() async {
injectScript('http://d3js.org/d3.v3.min.js');
final d3 = await js.context['d3'];
var svg = d3['select']('root')
['append']('svg')
['attr']('width', 100)
['attr']('height', 100);
svg['append']("circle")
['attr']("class", "circlemy")
['attr']("r", 40)
['attr']("cx", 50)
['attr']("cy", 50);
}
}
app_root.html:
<div class="host-root">Pages with circles</div>
app_root.css:
.host-root {
color: purple;
}
.circlemy {
fill: blue;
}
Since I use Angular2 components, my css file is transformed to following after build:
.host-root[_ngcontent-qxh-1] {
color: purple;
}
.circlemy[_ngcontent-qxh-1] {
fill: none;
}
and resulted html contains following code:
<div ng-app="">
<root _nghost-qxh-1="">
<div _ngcontent-qxh-1="" class="host-root">Page with circles</div>
<svg width="100" height="100">
<circle class="circlemy" r="40" cx="50" cy="50"></circle></svg>
</root></div>
I read that adding those _ngcontent-qxh-1 tags in Angular2 is called shiming. In https://github.com/angular/angular.dart/wiki/CSS-Shim I read that "Dynamically-created DOM will not be shimmed"
Is there a way I can use css for my svg circle?