I am currently working on implementing a directive that can draw a chart based on specified values. What I am aiming for is to pass the data necessary for the plot directly from the template rather than using ng-model, as my current solution requires. I have found that using ng-model and $scope.watch works well, however, it does not support filtered data and I do not require two-way binding. Ideally, the html structure I am looking for is:
<chart ???????="list | filter" />
The structure of the directive I envision is as follows:
return {
restrict: 'C',
link: function(scope, elem, attrs) {
var chart = null;
scope.$watch(????, function(v) {
if(!chart) {
chart = $.plot(elem, v, options);
elem.show();
} else {
chart.setData(v);
chart.setupGrid();
chart.draw();
}
});
}
};
Is there a more angular-friendly way to accomplish this task?