Home Setting your array index to selected from a angular bootstrap modal on close
Reply: 0

Setting your array index to selected from a angular bootstrap modal on close

user1522
1#
user1522 Published in June 19, 2018, 2:43 pm

I have been following the angular ui modal on this link https://angular-ui.github.io/bootstrap/#/modal.

Everything is working just fine, and I am able to select the index for the array $scope.comps= ['item1', 'item2', 'item3'].

My parent page, when closing the model has a form that shows only one comps at a time with next, previous, last, first buttons:

$scope.getNext = function () {
        $scope.index = $scope.index + 1;
        $scope.comp = $scope.comps[$scope.index];
    }
    $scope.getLast = function () {
        $scope.index = $scope.comps.length - 1;
        $scope.comp = $scope.comps[$scope.index];
    }

    $scope.getPrevious = function () {
        $scope.index = $scope.index - 1;
        $scope.comp = $scope.comps[$scope.index];
    }
    $scope.getFirst = function () {
        $scope.comp = $scope.comps[0];
    }

How do I set my $scope.comp, to the selected index after I close the modal

I have tried to set my $scope.comp in the $uibModalInstance.close function as below, but when I close the modal it doesn't take me to any $scope.comp and remains on the same.

$scope.ok = function () {
       $uibModalInstance.close($scope.comp = $scope.comps[$scope.selected.index]);
       ;
    };

OR

$scope.ok = function () {
       $uibModalInstance.close($scope.selected.index);
       $scope.comp = $scope.comps[$scope.selected.index]);

    };
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.508983 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO