Ionic Framework Popover JQuery addClass

我正在尝试将一个类添加到一个popover:

$('#popoverbutton').addClass('someclass'); 

我已经在文档中尝试了它并通过onclick =“myfunction();”发送它 ..

但它只是不会将类添加到打开弹出窗口时要调用的模板中的按钮。

我认为这是因为弹出窗口仍未打开,所以我可以在显示弹出窗口后执行此操作吗?

如果加载弹出窗口,我怎么能让它运行一些jquery?

这是控制器的代码:

 $scope.usefulData = {}; $ionicModal.fromTemplateUrl('templates/mypopover.html', { scope: $scope }).then(function(modal) { $scope.modalMypopover = modal; }); $scope.closeMypopover = function() { $scope.modalMypopover.hide(); }; $scope.mypopover = function() { $scope.modalMypopover.show(); }; $scope.doMypopover = function() { console.log('Doing mypopover'); $timeout(function() { $scope.closeMypopover(); }, 1000); }; 

你为什么不采用Angular绑定? 我的意思是:在modal.shown事件处理程序上设置一个变量,并使用ng-class class根据该值应用特定的类。

请参阅下面的代码:

 angular.module('ionicApp', ['ionic']) .controller('AppCtrl', function($scope, $ionicModal, $timeout) { $scope.btnClass = 'button-positive'; $ionicModal.fromTemplateUrl('templates/mypopover.html', { scope: $scope }).then(function(modal) { $scope.modalMypopover = modal; }); $scope.$on('modal.shown', function() { $scope.btnClass = 'button-assertive myClass'; }); $scope.closeMypopover = function() { $scope.modalMypopover.hide(); $scope.btnClass = 'button-positive'; }; $scope.mypopover = function() { $scope.modalMypopover.show(); }; $scope.doMypopover = function() { console.log('Doing mypopover'); $timeout(function() { $scope.closeMypopover(); }, 1000); }; }); 
 .myClass { font-weight: bold; font-style: italic; color: blue !important; } 
     Ionic Modal      

Popover