I'm trying to use MovilizerJS with the Ionic Framework to create a HTML5 screen. I try to reference te MovilizerJS from within the App.js files generated by Ionic. I added the MovilizerJS files in the plugins folder and added the Cordova.js file containing.
var oHead = document.getElementsByTagName('HEAD').item(0);
var oScript = document.createElement("script");
oScript.type = "text/javascript";
oScript.src = "plugins/Movilizer.js";
oHead.appendChild(oScript);
It seems though that when i load the HTML5 page inside a browser (or html5 view in the movelet) the MovilizerJS does not get loaded. The following error appears on the browser:
Module 'movilizer' is not available!
Perhaps I need to add this as a Module to the Angular Framework, but when i try to added it to the modules it still gives me errors. My HTML files contains the script-tag for movilizer:
<script src="plugins/Movilizer.js"></script>
My App.js code currently looks like this:
angular.module('starter', ['ionic'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
StatusBar.styleDefault();
}
});
}).factory('MovilizerExtender', function ($rootScope) {
return {
startUpMovilizer: function(){
movilizer.readGlobalVariable("testTable",this.successCallback,this.errorCallback);
},
successCallback: function(result){
$rootScope.routestops = [
{ ontvNaam: 'nice' },
{ ontvNaam: 'it' },
{ ontvNaam: 'is' },
{ ontvNaam: 'working' }
];
},
errorCallback: function(){
console.log('failed');
}
}
}).controller("RoutestopCtrl", function($scope, $rootScope, MovilizerExtender) {
MovilizerExtender.startUpMovilizer();
$scope.routestops = $rootScope.routestops;
$rootScope.$watch('routestops', function(){
$scope.routestops = $rootScope.routestops;
});
});
When i directly call the succesCallback method and comment the line: movilizer.readGlobalVariable(...), it no longer tries to access the movilizerJS and the page works. Also note that the Movilizer.js file contains the readGlobalVariable method described in the app.js code. Any help or ideas would be appreciated.