У меня есть эта директива, и всякий раз, когда я делаю ng-repeat
, по какой-то причине, когда я использовал console.log
, она всегда возвращает последние данные из ng-repeat
.
(function () {
'use strict';
angular
.module('app.schoolAdmin')
.directive('barGraph', barGraph);
barGraph.$inject = ['$timeout'];
function barGraph ($timeout) {
var scope;
var element;
return {
link: link,
restrict: 'EA',
scope: {
data: '=',
onClick: '&',
methods: '='
}
};
function init () {
console.log("DATA", scope.data);
}
function link (_scope, _element) {
scope = _scope;
element = _element;
$timeout(function () {
init();
}, 0);
}
}
})();
, вот кодng-repeat. (данные при использовании json pipe верны.)
<div class="col-md-3"
ng-repeat="(key, group) in vm.analyticsData">
{{group | json}}
<h1>{{ key }}</h1>
<div class="charts-container">
<div class="chart-block">
<bar-graph data="group"></bar-graph>
</div>
</div>
</div>