All the issues and solutions discussed there also apply here.
Anyway, initially I also couldn’t get it working, the trick was to NOT call “$urlRouterProvider.otherwise(…)” when configuring your “$stateProvider”. So, if in your app.js you have something like this:
$stateProvider
.state('app', {
url: "/app",
abstract: true,
templateUrl: "js/app/menu/menu.html"
})
.state('app.auth', {
url: "/auth",
abstract: true,
template: '<ion-view/>'
});
// THE STANDARD IONIC STARTER APPS HAVE THIS LINE -
// REMOVE THIS OR COMMENT IT OUT!
// $urlRouterProvider.otherwise('/app/playlists'); // commented out
then make sure to REMOVE or COMMENT OUT the “$urlRouterProvider.otherwise(…)” call.
Actually this solution was already discussed in the thread I mentioned:
Hi
I added the factory ‘Application’ in app.js at the end of the chain and the app.run goes like this:
run(function($ionicPlatform,$state) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory
// bar above the keyboard
// for form inputs)
<!--if(navigator && navigator.splashscreen) navigator.splashscreen.hide();-->
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
window.cordova.plugins.Keyboard.disableScroll(true); }
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
})
if (Application.isInitialRun()) {
//alert("Initial");
Application.setInitialRun(false);
$state.go('prelogin');
//$location.path('/loginurl');
}
else {
//alert("No");
//$location.path('/login');
$state.go('login');
}
})
The issue is that I am getting a blank white screen when the app is run.Can you please tell me where I have gone wrong?
Thanks in advance,
Sunita
Does it work in “ionic serve” but not on a device? If you run the app on an Android device you should run “adb logcat” to see what is going on, for sure there’s an error stacktrace.
Actually I am coding in Eclipse and testing in emulator.
Now I have shifted the factory ‘Application’ to services,js
This is how the app.js file starts like this:
angular.module(‘starter’,
[ ‘ionic’, ‘starter.controllers’, ‘starter.services’, ‘starter.directives’ ]) services.js is as follows:
angular.module(‘starter.services’, [‘ionic’])
.service(‘PerformService’, function($http) {
return {
…
};
return $http.post(‘http://…’,tagdata);
}
}
})
.factory(‘Application’, function ($window) {
return {
setInitialRun = function (initial) {
$window.localStorage[“initialRun”] = (initial ? “true” : “false”);
},
isInitialRun = function () {
var value = $window.localStorage[“initialRun”] || “true”;
return value == “true”;
}
};
});
The error shown in logcat is:
Error: [$injector:nomod] Module ‘starter.services’ is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
Hi Ieob,
I found out the reason for the error:
.factory(‘Application’, function ($window) {
return {
setInitialRun = function (initial) {
$window.localStorage[“initialRun”] = (initial ? “true” : “false”);
},
isInitialRun = function () {
var value = $window.localStorage[“initialRun”] || “true”;
return value == “true”;
}
};
});
The token ‘=’ when replaced with ‘:’ solved the issue.