0👍
With local scope parameters defined by “@” you only get one way binding of String values into the directive. There is no way back and such as the Arrays you set the scope variables to are only local to the directive. Plus @ only allows string values, no objects or arrays.
Instead define your directive like this (from your pastebin):
fitAdmin.directive('exercice', function(Client) {
return {
template: '<canvas id="bar" class="chart chart-bar" data="poidsExo" labels="exoLabel"></canvas> ',
restrict: 'EA',
scope: {
poidsExo: '=',
exoLabel: '=',
},
link : function (scope, element, attrs) {
Client.getClientResultsExercice(attrs.id, attrs.name).then (function (data) {
scope.poidsExo = [];
scope.exoLabel = [];
var dateTemp;
angular.forEach(data, function (data) {
if (data.date !== dateTemp) {
scope.poidsExo.push(data.poids);
scope.exoLabel.push(data.date);
dateTemp = data.date;
};
});
})
},
};
});
- [Chartjs]-How can I put sign (%) on data in ChartJS?
- [Chartjs]-How to install Chart.js and angular-chart.js (Error: Chart.js library needs to be included)
Source:stackexchange.com