m-e-conroy / angular-dialog-service

A complete AngularJS service with controllers and templates for generating application modals and dialogs for use with Angular-UI-Bootstrap and Twitter Bootstrap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

prompt dialog (solution source code included)

opened this issue · comments

Hi,

Your plugin is so helpful. Here is my minor contribution:

I have included the solution for prompt dialog but I don't know how to use Git, sorry. Here is it:

promtCtrl line 93:

/**
 * Prompt Dialog Controller
 */
ctrlrs.controller('promptDialogCtrl',['$scope','$modalInstance','$translate','data',function($scope,$modalInstance,$translate,data){
    //-- Variables -----//

    $scope.header = (angular.isDefined(data.header)) ? data.header : $translate.instant('DIALOGS_CONFIRM');
    $scope.msg = (angular.isDefined(data.msg)) ? data.msg : $translate.instant('DIALOGS_ERROR_MSG');
    $scope.icon = (angular.isDefined(data.fa) && angular.equals(data.fa,true)) ? 'fa fa-warning' : 'glyphicon glyphicon-warning-sign';

    //-- Methods -----//
    $scope.ok = function(){
        $modalInstance.close($scope.outputText);
    };

    $scope.cancel = function(){
        $modalInstance.dismiss();
        $scope.$destroy();
    }; // end close
}]); // end ErrorDialogCtrl

prompt method on dialogs

/**
* prompt Dialog
*
* @param header string
* @param msg string
* @param opts object
*/
prompt : function(header,msg,opts){
opts = _setOpts(opts);

                return $modal.open({
                    templateUrl : '/dialogs/prompt.html',
                    controller : 'promptDialogCtrl',
                    backdrop: opts.bd,
                    backdropClass: opts.bdc,
                    keyboard: opts.kb,
                    windowClass: opts.wc,
                    size: opts.ws,
                    animation: opts.anim,
                    resolve : {
                        data : function(){
                            return {
                                header : angular.copy(header),
                                msg : angular.copy(msg),
                                fa : _fa
                            };
                        }
                    }
                }); // end modal.open
            }, // end prompt

Template sample:

    <div class="modal-header dialog-header-prompt">
    <button type="button" class="close" ng-click="cancel()" class="pull-right">&times;</button>
    <h4 class="modal-title text-info"><span class="{{icon}}"></span> {{header}}</h4>
   </div>
<div class="modal-body">
    <div class=" text-info"  ng-bind-html="msg"></div>
    <div class="input-message"><input ng-model="outputText"></div>


</div>

<div class="modal-footer">
    <button type="button" class="btn btn-primary " ng-click="ok()">{{"dialogs_ok" | translate}}
    </button>
    <button type="button" class="btn btn-default" ng-click="cancel()">{{"dialogs_cancel" | translate}}
    </button>
</div>

Thank you

Hey, thanks. I'll try to include it when I can. I'm fairly busy lately so when I have some down time I'll add it.