Skip to content

Commit 924ec70

Browse files
committed
fix updateData function
1 parent 1d7995a commit 924ec70

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/angular-fusioncharts.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,10 @@
198198
return {
199199
scope: scope,
200200
link: function(scope, element, attrs) {
201-
function updateData(key, data) {
202-
if (key) {
203-
scope.datasourceDt.key = data;
204-
chart.setJSONData(scope.datasourceDt);
205-
}
201+
function updateData() {
202+
// no need to check for key. datasourceDt is 2 way binded.
203+
// also scope.datasourceDt.key = data; is logically wrong.
204+
chart.setJSONData(scope.datasourceDt);
206205
}
207206

208207
function createWatchersForAttrs(datasource) {
@@ -212,7 +211,7 @@
212211
scope.$watch(
213212
'datasourceDt.' + key,
214213
function(newData, oldData) {
215-
if (newData !== oldData && isDeep) updateData(key, newData);
214+
if (newData !== oldData && isDeep) updateData();
216215
},
217216
isDeep
218217
);
@@ -747,7 +746,7 @@
747746
scope.$watch(
748747
'datasourceDt.data',
749748
function(newData, oldData) {
750-
if (newData !== oldData) updateData(newData, 'data');
749+
if (newData !== oldData) updateData();
751750
},
752751
false
753752
);

0 commit comments

Comments
 (0)