javascript - Angularjs Array indexes not getting displayed -


this going dumb question stuck long on piece, , fresh pair of eyes maybe see issue.

i have 2 arrays 1 holds static data , temporarily holds single index of main array.

i want display temporary array values on popup , if new index chosen data should cange next array value.

my issue is: if try display fixed array values gets displayed fine, if try display temporary array values nothing shows. using exact same technique display both , static array works.

html

  <button type="button" class="btn btn-default btn-block" ng-model="modela" ng-click="$ctrl.id(1);">more info</button>  //popup <script type="text/ng-template" id="mymodalcontent.html">     <div ng-controller="popupctrl $ctrl">         <div class="modal-header">             <h2 class="modal-title" id="modal-title">{{$ctrl.array2}}</h2>         </div>         <div class="modal-body" id="modal-body">             <h3>{{$ctrl.array1}}</h3>             <p>{{$ctrl.array1}}</p>         </div>         <div class="modal-footer">             <button class="btn btn-primary" type="button" ng-click="$ctrl.ok()">ok</button>             <button class="btn btn-warning" type="button" ng-click="$ctrl.cancel()">cancel</button>         </div>     </div>  </script> 

javasccript arrays

    $ctrl.array1 = [{id: 1, name: 'name1'},{id: 2, name: 'name2'}]     $ctrl.array2 = [];  $ctrl.id = function (modela) {         console.log('modela', modela);          (var = 0; < $ctrl.array1.length; i++) {              if ($ctrl.array1[i].id == modela) {                 $ctrl.array2.push($ctrl.array1[i]);              }         }         $ctrl.open('lg');     }       $ctrl.open = function (size) {              var modalinstance = $uibmodal.open({                  animation: $ctrl.animationsenabled,                 arialabelledby: 'modal-title',                 ariadescribedby: 'modal-body',                 templateurl: 'mymodalcontent.html',                 controller: 'modalinstancectrl',                 controlleras: '$ctrl',                 size: size,                 resolve: {                     items: function () {                         return $ctrl.array2;                     }                 }             }); 


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -