diff --git a/js/angular/service/popup.js b/js/angular/service/popup.js index 6e37defd345..84a00cc5dd8 100644 --- a/js/angular/service/popup.js +++ b/js/angular/service/popup.js @@ -464,8 +464,13 @@ function($ionicTemplateLoader, $ionicBackdrop, $q, $timeout, $rootScope, $docume function showPrompt(opts) { var scope = $rootScope.$new(true); scope.data = {}; + var text = ''; + if(opts.template && /<[a-z][\s\S]*>/i.test(opts.template) === false){ + text = ''+opts.template+''; + delete opts.template; + } return showPopup( extend({ - template: '', scope: scope, buttons: [{ diff --git a/test/unit/angular/service/popup.unit.js b/test/unit/angular/service/popup.unit.js index 0a4e8e6fa1f..1d072fa87ab 100644 --- a/test/unit/angular/service/popup.unit.js +++ b/test/unit/angular/service/popup.unit.js @@ -277,5 +277,16 @@ describe('$ionicPopup service', function() { $timeout.flush(); expect($ionicBackdrop.release).toHaveBeenCalled(); })); + it('template should only overwrite prompt input if it includes html', inject(function($timeout) { + spyOn($ionicPopup, '_createPopup'); + $ionicPopup.prompt({template: "Tacos!"}); + params = $ionicPopup._createPopup.mostRecentCall.args; + expect(params[0].template.indexOf('Tacos!')).toEqual(0); + expect(params[0].template.indexOf(''}); + params = $ionicPopup._createPopup.mostRecentCall.args; + expect(params[0].template.indexOf('')).toEqual(0); + })); }); });