6

我有以下代码:

$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();
        };

使用以下方法从视图中调用:

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

所以我无法将模板的 URL 作为参数传递。

请问我该怎么做?

感谢您的任何建议。

4

1 回答 1

6

我使用以下代码修改解决了它:

  // 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();
        };
于 2015-01-12T10:01:04.083 回答