How to add controller to side-menu


Hi everybody, i faced with the problem that i added ng-controller in my side-menus, and my side-menus is placed in my index.html like this:

<body ng-app="starter">
  <ion-side-menus enable-menu-with-back-views="false" ng-controller="SideMenuCtrl">
      <ion-nav-bar class="my-bar">
        <ion-nav-back-button id="my-back-button" class="button-clear">
          <i class="ion-chevron-left"></i>
        <ion-nav-buttons side="left">
          <button class="button button-icon button-clear mybutton bot" menu-toggle="left">
              <i class="my-navicon"></i>
          <img class="title-image" src="css/img/extractor-logo.png">

    <ion-side-menu side="left" class="sidemenu height">
          <a href="#/app/options" class="button button-icon button-clear" menu-toggle="left"><i class="my-gear-icon"></i></a>
        <hr class="longhr">
      <div class="all-projects"><h3>{{&apos;allProjects&apos; | translate}}</h3></div>
      <div ng-repeat="item in projects">
        <hr class="shorthr">
        <div class="project">
          <i class="custom-icon-{{}} icon-color-assertive my-circle-icon"></i>
          <section class="myseaction">
            <ul type="disc">

In this case i’ve got two problems:

  1. my side-menus controller works on every page, in this controller i’m working with my local database, and event like $scope.$on('$ionicView.eneter', function() {}) works not as i want, because it works on every page of my application.

  2. the second problem is that, my code works twice everytime, here is my sideMenuCtrl:

    extractor.controller(‘SideMenuCtrl’, [
    function($scope, loginService, DataService, $ionicPlatform, $ionicHistory) {

    var setProjects = function() {
    }; // setProjects

    var getProjects = function() {
    DataService.getProjectsFromDB().then(function(res) {
    $scope.projects = res;
    // console.log($scope.projects);
    }; // getProjects

    $scope.$on(’$ionicView.enter’, function() {

    }]); // SideMenuCtrl

Don’t know how why my code working every time two times, every data sets to the database two times, and displays two times, alerts two times, i’m trying to fix this second day, and have no more ideas, so if you give me some hint, i will be appreciate, THANKS!