Commit 155974d4b94218cd584f80eed653664fb34c54ed
Exists in
master
Merge branch 'master' into 'master'
modal prompt See merge request !4
Showing
3 changed files
Show diff stats
src/js/controller.js
| ... | ... | @@ -32,4 +32,17 @@ angular.module('focaModal') |
| 32 | 32 | $uibModalInstance.close($scope.fecha); |
| 33 | 33 | }; |
| 34 | 34 | } |
| 35 | +]) | |
| 36 | +.controller('focaModalPromptController', [ | |
| 37 | + '$uibModalInstance', '$scope', 'titulo', 'initValue', | |
| 38 | + function($uibModalInstance, $scope, titulo, initValue) { | |
| 39 | + $scope.titulo = titulo; | |
| 40 | + $scope.value = initValue; | |
| 41 | + $scope.cancelar = function() { | |
| 42 | + $uibModalInstance.dismiss(); | |
| 43 | + }; | |
| 44 | + $scope.aceptar = function() { | |
| 45 | + $uibModalInstance.close($scope.value); | |
| 46 | + }; | |
| 47 | + } | |
| 35 | 48 | ]); |
src/js/service.js
| ... | ... | @@ -65,6 +65,22 @@ angular.module('focaModal') |
| 65 | 65 | return resultado; |
| 66 | 66 | } |
| 67 | 67 | ); |
| 68 | + }, | |
| 69 | + prompt: function(titulo, initValue){ | |
| 70 | + return $uibModal.open({ | |
| 71 | + templateUrl: 'modal-prompt.html', | |
| 72 | + controller: 'focaModalPromptController', | |
| 73 | + size: 'md', | |
| 74 | + resolve: { | |
| 75 | + titulo: function() {return titulo;}, | |
| 76 | + initValue: function() {return initValue;} | |
| 77 | + } | |
| 78 | + }) | |
| 79 | + .result.then( | |
| 80 | + function(resultado) { | |
| 81 | + return resultado; | |
| 82 | + } | |
| 83 | + ); | |
| 68 | 84 | } |
| 69 | 85 | }; |
| 70 | 86 | } |
src/views/modal-prompt.html
| ... | ... | @@ -0,0 +1,13 @@ |
| 1 | +<div class="modal-header"> | |
| 2 | + <h4 ng-bind="titulo"></h4> | |
| 3 | +</div> | |
| 4 | +<div class="modal-body"> | |
| 5 | + <input | |
| 6 | + type="text" | |
| 7 | + class="form-control" | |
| 8 | + ng-model="value"> | |
| 9 | +</div> | |
| 10 | +<div class="modal-footer"> | |
| 11 | + <button class="btn btn-primary" ng-click="aceptar()" foca-focus="true">Aceptar</button> | |
| 12 | + <button class="btn btn-default" ng-click="cancelar()">Cancelar</button> | |
| 13 | +</div> |