title: AngularJS ng-repeat Post Value not getting in proper pattern
body: <p>I'm new in AngularJS I want to get post value in proper format. When I use
  field name as key in checkbox it gives proper value but when I use id as key it does't.</p>
  
  <p>Given below code with name as key</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module('app', []);
  
  app.controller('MainCtrl', function($scope) {
    $scope.mainMenu = {};
    $scope.submenu = {};
    $scope.pagemenu ={};
    $scope.menu   = {};
    
    $scope.menus  = [
      {"menuID":"11","sub_menu":"N","name":"dashboard","sub_menus":""},
      {"menuID":"1","sub_menu":"Y","name":"settings","sub_menus":[{"sub_menuID":"1","name":"settings1","page":"Y","pages":[{"pageID":"1","name":"page1"},{"pageID":"2","name":"page2"}]},{"sub_menuID":"2","name":"settings2","page":"N","pages":""}]},
      {"menuID":"2","sub_menu":"Y","name":"help","sub_menus":[{"sub_menuID":"3","name":"help1","page":"N","pages":""},{"sub_menuID":"4","name":"help2","page":"N","pages":""}]},
      {"menuID":"3","sub_menu":"Y","name":"contact","sub_menus":[{"sub_menuID":"5","name":"contact1","page":"N","pages":""},{"sub_menuID":"6","name":"contact2","page":"N","pages":""}]}
    ];
    
    $scope.assignValue = function(menuId,submenuId,pageId){
      /* if(!$scope.mainMenu[menuId]&amp;&amp;!$scope.submenu[menuId]&amp;&amp;!$scope.pagemenu[menuId]){
        delete($scope.mainMenu[menuId]);
        delete($scope.submenu[menuId]);
        delete($scope.pagemenu[menuId]);
      } */
      
      $scope.menu=Object.assign({},$scope.mainMenu, $scope.submenu,$scope.pagemenu);
      console.log($scope.menu);
    }
    
    $scope.submit = function(){
      // alert(JSON.stringify($scope.menu));
      console.log(JSON.stringify($scope.menu));
      console.log($scope.menu);
    }
    
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;rules&lt;/title&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.3/angular.min.js"&gt;&lt;/script&gt;
    &lt;script src="mainCtrl.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body ng-app="app"&gt;
    
   &lt;div ng-controller="MainCtrl"&gt;
        &lt;form ng-submit="submit()"&gt;
          &lt;ul&gt;
            &lt;li ng-repeat="x in menus"&gt;
              &lt;input type="checkbox" ng-change= "assignValue(x.menuID)" ng-model="mainMenu[x.name]" ng-true-value="'{{x.menuID}}'"&gt;{{x.name}}
              &lt;ul ng-if="[x.sub_menu] == 'Y'"&gt;
                &lt;li ng-repeat="subMenu in x.sub_menus"&gt;
                  &lt;input type="checkbox" ng-model="submenu[x.name][subMenu.name]" ng-true-value="'{{subMenu.sub_menuID}}'" ng-change= "assignValue(x.menuID,subMenu.sub_menuID,null)"&gt;{{subMenu.name}}
                  &lt;ul ng-if="[subMenu.page] == 'Y'"&gt;
                    &lt;li ng-repeat="page in subMenu.pages"&gt;
                      &lt;input type="checkbox" ng-model="pagemenu[x.name][subMenu.name][page.name]"  ng-true-value="'{{page.pageID}}'" ng-change= "assignValue(x.menuID,subMenu.sub_menuID,page.pageID)"&gt;{{page.name}}
                    &lt;/li&gt;
                  &lt;/ul&gt;
                &lt;/li&gt; 
              &lt;/ul&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
          
          &lt;button&gt;Submit&lt;/button&gt;
        &lt;/form&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>And the code with id as key</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module('app', []);
  
  app.controller('MainCtrl', function($scope) {
    $scope.mainMenu = {};
    $scope.submenu = {};
    $scope.pagemenu ={};
    $scope.menu   = {};
    $scope.menus  = [
      {"menuID":"11","sub_menu":"N","name":"dashboard","sub_menus":""},
      {"menuID":"1","sub_menu":"Y","name":"settings","sub_menus":[{"sub_menuID":"1","name":"settings1","page":"Y","pages":[{"pageID":"1","name":"page1"},{"pageID":"2","name":"page2"}]},{"sub_menuID":"2","name":"settings2","page":"N","pages":""}]},
      {"menuID":"2","sub_menu":"Y","name":"help","sub_menus":[{"sub_menuID":"3","name":"help1","page":"N","pages":""},{"sub_menuID":"4","name":"help2","page":"N","pages":""}]},
      {"menuID":"3","sub_menu":"Y","name":"contact","sub_menus":[{"sub_menuID":"5","name":"contact1","page":"N","pages":""},{"sub_menuID":"6","name":"contact2","page":"N","pages":""}]}
    ];
    
    $scope.assignValue = function(menuId,submenuId,pageId){
      /* if(!$scope.mainMenu[menuId]&amp;&amp;!$scope.submenu[menuId]&amp;&amp;!$scope.pagemenu[menuId]){
        delete($scope.mainMenu[menuId]);
        delete($scope.submenu[menuId]);
        delete($scope.pagemenu[menuId]);
      }*/
      
      $scope.menu=Object.assign({},$scope.mainMenu, $scope.submenu,$scope.pagemenu);
      console.log($scope.menu);
    }
    
    $scope.submit = function(){
      // alert(JSON.stringify($scope.menu));
      console.log(JSON.stringify($scope.menu));
      console.log($scope.menu);
    }
    
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;rules&lt;/title&gt;
    &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.3/angular.min.js"&gt;&lt;/script&gt;
    &lt;script src="mainCtrl.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body ng-app="app"&gt;
    
   &lt;div ng-controller="MainCtrl"&gt;
        &lt;form ng-submit="submit()"&gt;
          &lt;ul&gt;
            &lt;li ng-repeat="x in menus"&gt;
              &lt;input type="checkbox" ng-change= "assignValue(x.menuID)" ng-model="mainMenu[x.menuID]" ng-true-value="'{{x.menuID}}'"&gt;{{x.name}}
              &lt;ul ng-if="[x.sub_menu] == 'Y'"&gt;
                &lt;li ng-repeat="subMenu in x.sub_menus"&gt;
                  &lt;input type="checkbox" ng-model="submenu[x.menuID][subMenu.sub_menuID]" ng-true-value="'{{subMenu.sub_menuID}}'" ng-change= "assignValue(x.menuID,subMenu.sub_menuID,null)"&gt;{{subMenu.name}}
                  &lt;ul ng-if="[subMenu.page] == 'Y'"&gt;
                    &lt;li ng-repeat="page in subMenu.pages"&gt;
                      &lt;input type="checkbox" ng-model="pagemenu[x.menuID][subMenu.sub_menuID][page.pageID]"  ng-true-value="'{{page.pageID}}'" ng-change= "assignValue(x.menuID,subMenu.sub_menuID,page.pageID)"&gt;{{page.name}}
                    &lt;/li&gt;
                  &lt;/ul&gt;
                &lt;/li&gt; 
              &lt;/ul&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
          
          &lt;button&gt;Submit&lt;/button&gt;
        &lt;/form&gt;
    &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>