Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError - cannot read property 'resolve' of null #92

Closed
ajoslin103 opened this issue Aug 1, 2015 · 1 comment
Closed

TypeError - cannot read property 'resolve' of null #92

ajoslin103 opened this issue Aug 1, 2015 · 1 comment

Comments

@ajoslin103
Copy link
Contributor

I'm getting: TypeError - cannot read property 'resolve' of null
at line 91 of angular-modail-service version: 0.6.7

           //  Resolve the 'close' promise.
           closeDeferred.resolve(result);

I don't understand this, I'm using it very simply...

-- usage --

      // modalTemplateData is a service containing a hash - we load it here, and use in the controller
      modalTemplateData.setData({ errorTitle: 'Error', errorMessage: $log.buffer().join('<br>') });
      ModalService.showModal({
        templateUrl: ENV.errorReportModal,
        controller: 'SimpleModalCtrl'
      }).then(function(modal) {
        modal.element.modal();
        modal.close.then(function() {
          $log.reset();
        });
      });

-- template --

<div class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" ng-click="close(-1)" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">{{errorTitle}}</h4>
            </div>
            <div class="modal-body">
                <p ng-bind-html="errorMessage"></p>
                <div class="Unauthorized"></div>
            </div>
            <div class="modal-footer">
                <button type="button" ng-click="close(-1)" class="btn btn-default" data-dismiss="modal">OK</button>
            </div>
        </div>
    </div>
</div>

-- controller --

'use strict';

(function () {

    function controllerFn ($scope, $element, close, modalTemplateData) {

            // this is supposed to catch clicks on the backdrop and close the dialog
        $element.on('hidden.bs.modal', close);

            // we extend scope with this hash so template substitutions can be customized
        angular.extend($scope,modalTemplateData.getData());

        $scope.close = function(result) {
            close(result, 500); // close, but give 500ms for bootstrap to animate
        };

    }

})();
@ajoslin103
Copy link
Contributor Author

this was the culprit

        // this is supposed to catch clicks on the backdrop and close the dialog
        $element.on('hidden.bs.modal', close);

apparently I had to add the corresponding .off

        $scope.close = function(result) {
            $element.off('hidden.bs.modal');
            close(result, 500); // close, but give 500ms for bootstrap to animate
        };

or maybe not use that close anyway, I didn't notice it was from 2012 -- dialog closes on click on backdrop anyway


best to just ignore this whole issue

apologies for wasting your time

al;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant