Ionic: popover from template> How to dynamically pass parameter url?

I have the 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 the view using:

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

Therefore, I cannot pass the URL of the template as a parameter.

How can i do this?

Thanks for any advice.

+6
source share
1 answer

I solved this using the 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(); }; 
+6
source

Source: https://habr.com/ru/post/980768/


All Articles