I have a modal that I want to be able to have displayed from any view within my Ionic App… so I put the modal logic into a service. The obvious problem is that the service will need access to the current $scope. I obviously don’t want to have to register the current $scope on every view-change. What I came up with works just fine, but I wanted to know if anyone saw any problems with it…
SyncService.prototype.showInfo = function(){
var self = this;
this.$ionicModal.fromTemplateUrl("modules/sync/sync-info-modal.html", {
scope: angular.element( document.getElementsByTagName('ion-content')[0] ).scope()
})
.then( function( modal ){
self.syncModal = modal;
self.syncModal.show();
});
}
SyncService.prototype.hideSyncModal = function(){
if( this.syncModal ){
this.syncModal.hide();
this.syncModal.remove();
}
}
… the scope line in particular is what I am curious about. I figured there should always be at least one ion-content… Thanks!