This is probably going to be a dumb question but I am stuck too long on this piece, and a fresh pair of eyes could maybe see the issue.
I have two arrays one that holds static data and another that temporarily holds a single index of the main array.
I want to display the temporary array values on a popup and if the new index is chosen the data should cange to the next array value.
My issue is: If I try to display my fixed array values it gets displayed fine, but if I try to display the temporary array values nothing shows. I am using the exact same technique to display both and only the 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 as $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);
for (var i = 0; i < $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;
}
}
});