Ninoop p george Ninoop p george - 10 months ago 65
AngularJS Question

$scope inside $ionicplatform doesnt work

I have been developing an application, but this doesnt seems to work. normally if we add a value to the scope i think it needs to get updated in the application.. here is the index.html

<body ng-app="starter">
<ion-nav-bar class="top-nav">

<ion-content class="body" ng-controller="frontpage">
ss {{njk}} dd
<ion-side-menu side="left">


and here is the app.js

var main=angular.module('starter', ['ionic','ngCordova'])
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
if(window.StatusBar) {


main.controller("frontpage", function($scope,$cordovaFile,$ionicPlatform) {
$ionicPlatform.ready(function() {

the problem is with the $scope.njk . I have added it inside the $ionicPlatform.ready and have assigned the value, but it doesnt reflect in the app. but the alert box is coming with the value. I need it inside the ready function badly. cause cordova.file wont work outside that. I have tried the $rootScope too. But it doesnt seems to work.


Try it using:

$ionicPlatform.ready(function() {
  $scope.$apply(function () {

Angular usually handles digesting automatically but however if you change any model outside of the Angular context (in this case the $ionicPlatform.ready function), then you need to inform Angular of the changes by calling $apply() manually. It’s like telling Angular that you are changing some models and it should fire the watchers so that your changes propagate properly.