fix(view): don't affect history when inside a modal

Closes #1667
This commit is contained in:
Andrew
2014-07-07 13:38:28 -06:00
parent 5da1ecd0e2
commit b7f45e7ca5
3 changed files with 17 additions and 4 deletions

View File

@@ -8,6 +8,7 @@ IonicModule
restrict: 'E',
transclude: true,
replace: true,
controller: [function(){}],
template: '<div class="modal-backdrop">' +
'<div class="modal-wrapper" ng-transclude></div>' +
'</div>'

View File

@@ -35,13 +35,17 @@ IonicModule
return {
restrict: 'EA',
priority: 1000,
require: '^?ionNavBar',
require: ['^?ionNavBar', '^?ionModal'],
compile: function(tElement, tAttrs, transclude) {
tElement.addClass('pane');
tElement[0].removeAttribute('title');
return function link($scope, $element, $attr, navBarCtrl) {
if (!navBarCtrl) {
return function link($scope, $element, $attr, ctrls) {
var navBarCtrl = ctrls[0];
var modalCtrl = ctrls[1];
//Don't use the ionView if we're inside a modal or there's no navbar
if (!navBarCtrl || modalCtrl) {
return;
}

View File

@@ -21,13 +21,21 @@ describe('ionView directive', function() {
return el;
}
it('should remove title & add pane, even with no navbar', inject(function($compile, $rootScope) {
it('should only remove title & add pane with no navbar', inject(function($compile, $rootScope) {
var el = $compile('<ion-view title="1">')($rootScope.$new());
$rootScope.$apply();
expect(el.hasClass('pane')).toBe(true);
expect(el[0].getAttribute('title')).toBe(null);
}));
it('should only remove title & add pane in a modal',inject(function($compile, $rootScope) {
var el = $compile('<ion-modal><ion-view title="1"></ion-modal>')($rootScope.$new());
var view = jqLite(el[0].querySelector('.pane'));
$rootScope.$apply();
expect(view.hasClass('pane')).toBe(true);
expect(view[0].getAttribute('title')).toBe(null);
}));
it('should have content inside', function() {
var el = setup(null, null, '<b>some</b> html');
expect(el.html()).toBe('<b>some</b> html');