DOM elements not ready in AngularJS Directular link () function

3 answers

Use the timeout function in the link function if you want to manipulate a dom that has not yet been created. See this

+1
source

Have you tried something like this

 link: function(scope, element, attrs) { scope.chart = c3.generate({ bindto: element[0], data: { columns: [ ['data1', 30, 200, 100, 400, 150, 250], ['data2', 50, 20, 10, 40, 15, 25] ] } }); } 
0
source

Maybe using element.find ('# id') will help:

 link: function(scope, element, attrs) { var item = element.find('#somechartid'); scope.chart = c3.generate({ bindto: item, data: { columns: [ ['data1', 30, 200, 100, 400, 150, 250], ['data2', 50, 20, 10, 40, 15, 25] ] } }); } 
0
source

Source: https://habr.com/ru/post/972197/


All Articles