0

I really would like to convert the following code to angular 2. Would it consist of writing alot of extra logic? Notice how this is simple and straight to the point.

I have a modal service

angular.module('app').service('myModalService', function ($modal, $http, $filter, $document) {
this.QuestionModal = function (message, title, showButtonNoCancel, buttonYesOK, buttonNoCancel) {
        return $modal.open({
            backdrop: 'static',
            keyboard: false,
            templateUrl: 'Scripts/Services/questionModal.html',
            controller: function ($scope, $modalInstance) {
                $scope.vm = { Message: '', Title: title };
                $scope.vm.Message = message;
                $scope.YesOkButton = buttonYesOK;                
                $scope.ButtonNoCancel = buttonNoCancel;                
                $scope.ShowButtonNoCancel = function () {
                    return showButtonNoCancel;
                }
                $scope.Ok = function () {
                    $modalInstance.close(true);
                }
                $scope.Cancel = function () {
                    $modalInstance.dismiss('cancel');
                }
            }
        });
    };

I call it like this and get the return value

 myModalService.QuestionModal("Do you want to delete the order?", 'Cancel Order', true, "Yes", "No").result.then(
            function () {
                 //handle yes function here
            },
            function () {
                //handle no function here
                return;
            });
CodeMan03
  • 570
  • 3
  • 18
  • 43
  • usually the $modal service is a thirdparty one. I suggest you try to find the equivalent of that service for angular2, or another one and see what it takes to get that working. Otherwise this is too broad to be addressed on SO. – toskv Oct 02 '17 at 13:45
  • $modal is angularui bootstrap – CodeMan03 Oct 02 '17 at 13:51
  • then I suggest you look at ng-bootstrap, it's the equivalent library for angular https://ng-bootstrap.github.io/#/components/modal/examples – toskv Oct 02 '17 at 13:53

0 Answers0