angularjs - Calling $wakanda.init multiple times from different Angular controllers -


i developing mobile application built in wakanda digital app factory 1.0.3 using ionic , angularjs 4d backend database.

i have 2 different 4d methods available through 4d-mobile via 2 separate 4d tables accessed via 2 different angular controllers:

.controller('homectrl', function($scope, $wakanda) {     $wakanda.init('servers').then(function(ds) {         ds.servers.www4dmionichomeoverview().$promise.then(function(event) {             $json = event.result;             $scope.overview = $json.servers;             $scope.healthcheck = $json.healthcheck;         }, function(err) {             debugger             console.log(err);         });     }, function(err) {         debugger         console.log(err);     }); })  .controller('errorlogctrl', function($scope, $wakanda) {     $wakanda.init('server_log').then(function(ds) {         ds.server_log.www4dmionicerrorlog().$promise.then(function(event) {             $json = event.result;             $scope.errors = $json;         }, function(e) {             debugger             console.log(e);         });     }, function(e) {         debugger         console.log(e);     }); }) 

i noticing strange issue calling these 4d methods in first 1 work second 1 fail, regardless of 1 call first. is, if call ds.server_log.www4dmionicerrorlog() first works subsequent calls ds.servers.www4dmionichomeoverview() fail until refresh browser.

the opposite true in if call ds.servers.www4dmionichomeoverview() first works subsequent calls ds.server_log.www4dmionicerrorlog() fail.


the error second method is:

ionic.bundle.js:25642 typeerror: cannot read property 'www4dmionichomeoverview' of undefined

or

ionic.bundle.js:25642 typeerror: cannot read property 'www4dmionicerrorlog' of undefined

depending on of 2 methods call first.


i curious if may related how calling $wakanda.init each controller. documentation not bad this.

would better setup angular service , resolve $wakanda in service?

replace

 $wakanda.init('servers').then(function(ds) {... 

by

$wakanda.init().then(function(ds) {... 

and same in controllers.

in case, recommend use $wakanda.init()


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -