christopherthielen / ui-router-extras

THIS PROJECT IS NO LONGER MAINTAINED -- Extras for UI-Router for AngularJS. Sticky States (a.k.a. parallel states), Deep State Redirect (for tab-like navigation), Future States (async state definition)
http://christopherthielen.github.io/ui-router-extras/
MIT License
917 stars 211 forks source link

Reduce boilerplate code #322

Open davidstellini opened 8 years ago

davidstellini commented 8 years ago

I prefer your architecture, but on the other hand, I much prefer the ui-router-uib-modal simplicity of modal : true, with a state rather than having to include all this:

function showModal($modal, $previousState) {
      $previousState.memo("modalInvoker"); // remember the previous state with memoName "modalInvoker"

      $modal.open({
        templateUrl: 'modal1.html',
        backdrop: 'static',
        controller: function($modalInstance, $scope) {
          var isopen = true;
          $modalInstance.result.finally(function() {
            isopen = false;
            $previousState.go("modalInvoker"); // return to previous state
          });
          $scope.close = function () {
            $modalInstance.dismiss('close');
          };
          $scope.$on("$stateChangeStart", function(evt, toState) {
            if (!toState.$$state().includes['modal1']) {
              $modalInstance.dismiss('close');
            }
          });
        }
      })
    }
  });