redrom
redrom

Reputation: 11642

Ionic : popover from template > How to pass param URL dynamically?

I have following code:

$ionicPopover.fromTemplateUrl('templates/popover_available_sounds.html', {
            scope: $scope,
        }).then(function(popover) {
            $scope.popover = popover;
        });

        // Display Popover
        $scope.openPopover = function($event) {
            $scope.popover.show($event);
        };

        $scope.closePopover = function() {
            $scope.popover.hide();
        };

Which is called from view using:

<button ng-click="openPopover($event)"  
class="button button-icon icon ion-plus-circled"></button>

So i'm not able to pass URL of the template as param.

How can i do it please?

Thanks for any advice.

Upvotes: 6

Views: 6336

Answers (1)

redrom
redrom

Reputation: 11642

I solved it using following code modification:

  // Display Popover
        $scope.openPopover = function($event, templateName) {
            // Init popover on load
            $ionicPopover.fromTemplateUrl('templates/'+templateName, {
                scope: $scope,
            }).then(function(popover) {
                $scope.popover = popover;
                $scope.popover.show($event);
            });
        };

        $scope.closePopover = function() {
            $scope.popover.hide();
        };

Upvotes: 6

Related Questions