Side menu doesn't refresh until open the app again


#1

Hello,
I have a side menu in my index.html file that show data returned from SQLite query, which are user favorite shows.
When the app run, it shows the data in SQLite without any problem, but if user add new favorite show the menu doesn’t refresh items until the user close and open the app again.
The code of the menu in index.html is the following:

  <!-- ion-side-menu-content
    This is where the main content of the application is inserted
     -->
  <ion-side-menu-content>
    <ion-nav-bar class="bar-royal">
      <ion-nav-back-button>
      </ion-nav-back-button>

      <ion-nav-buttons side="left">
        <button class="button button-icon button-clear ion-navicon" menu-toggle="left">
        </button>
      </ion-nav-buttons>
    </ion-nav-bar>
    <ion-nav-view></ion-nav-view>
  </ion-side-menu-content>

  <!-- ion-side-menu
    This is the main menu area (the menu that's revealed when the user
    presses the hamburger icon
     -->
  <ion-side-menu side="left"  ng-controller="menuCtrl">
    <ion-header-bar class="bar-dark">
      <h1 class="title">
        myTitle
      </h1>
    </ion-header-bar>
    <ion-content>
      <ion-list>
        <ion-item class="item-icon-left">
          <i class="icon ion-android-star"></i>
          Special Offers
        </ion-item>
        <ion-item class="item-icon-left">
          <i class="icon ion-android-add"></i>
          Add Your Business
        </ion-item>
        <ion-item class="item-icon-left">
          <i class="icon ion-speedometer"></i>
          Advertise With Us
        </ion-item>
        <ion-item class="item item-divider text-center">
          Your Favorites Places
        </ion-item>
        <ion-item ng-repeat="item in fav" ng-href="#/places/{{item.name}}" menu-toggle="left">
          {{item.name}}
        </ion-item>
      </ion-list>
    </ion-content>
  </ion-side-menu>
</ion-side-menus>

The menu Controller(menuCtrl) code:
`app.controller(‘menuCtrl’, function ($scope, $ionicPlatform, $cordovaSQLite) {
//$scope.fav = [];
var query = “SELECT * FROM favorite”;
$ionicPlatform.ready(function () {
alert(“ready-select”);
$cordovaSQLite.execute(db, query, []).then(function (res) {
$scope.fav = [];
alert(“fav”);
if (res.rows.length > 0) {
for (var i = 0; i < res.rows.length; i++) {
$scope.fav.push({
id: res.rows.item(i).id, //check id
name: res.rows.item(i).name
});
$scope.$apply();
}
} else {
//$scope.fav.push({
// name: “No Results Found”
//});
//$scope.$apply();
}
}, function (err) {
console.error(err);
});
});
});

My routes.js code is:

``angular.module(‘app.routes’, [])
.config(function ($stateProvider, $urlRouterProvider, $ionicConfigProvider) {
// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state’s controller can be found in controllers.js
$stateProvider

  .state('home', {
    url: '/home',
    cache: false,
    templateUrl: 'templates/home.html',
    controller: 'homeCtrl'
  })
  .state('places', {
    url: '/home/:locationID',
    cache: false,
    templateUrl: 'templates/places.html',
    controller: 'placesCtrl'
  })
  .state('hashtag', {
    url: '/places/:placeID',
    cache: false,
    templateUrl: 'templates/hashtag.html',
    controller: 'hashtagCtrl'
  })
$urlRouterProvider.otherwise('/home');
$ionicConfigProvider.backButton.previousTitleText(false); //hide back text from header

});
`
I tried to add to the index.html but it doesn’t work too.
any idea how can i solve this issue?
thanks.