Inconsistent behavior with root scope listening and ionicPlatform.ready

Ok, so this may be an Angular issue, not an Ionic issue, and when I say “Angular issue”, I mean a simple misunderstanding on my part.

I’ve got a pretty simple app that makes use of the camera in a controller. I want to ensure people don’t use the camera until deviceReady (or in our case, ionicPlatform.ready) has fired, so I simply disable the button. In my root app.js, I’m setting up a flag:

.run(function($rootScope,$ionicPlatform) {
$rootScope.appReady = {status:false};

$ionicPlatform.ready(function() {
	console.log('ionic Ready');
	$rootScope.appReady.status = true;
	console.log('in app.js, appReady is '+$rootScope.appReady.status);
	if(window.cordova && window.cordova.plugins.Keyboard) {
		cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
	}
	if(window.StatusBar) {
		StatusBar.styleDefault();
	}
    });
});

In my controller, I’ve got this (and my button’s disabled state is based on $scope.ready)

$rootScope.$watch('appReady.status', function() {
	console.log('watch fired '+$rootScope.appReady.status);
	if($rootScope.appReady.status) $scope.ready = true;
});

This worked fine for a while, and then began to fail. It was very random. Sometimes it worked - sometimes not. When it failed, if I opened up Safari, debugged, and hit Reload on the resources, it worked perfectly. It is something with how the app launches that is causing it to fail - but again - randomly.

Any ideas?

As just an FYI, it fails in Android too, on a real device.

Well heck, doing $rootScope.$apply() seemed to fix it right up. I didn’t think it was necessary.