How to pass the $event to the onEnter function of angular ui router state

1k views Asked by At

I have a question, maybe a stupid one, I am using ui-router state to open a modal just like explained here, except the part the modal is not ui-bootstrap's it is angular-material's $mdDialog. As some of you know that the $mdDialog slides in from the element clicked not from top-to-center like bootstrap-modal. Right now it is fading in no sliding, I would like to slide the modal from the element.
I did created a fiddle for this purpose.
Here is the code

var app = angular
  .module('myApp', ['ngAnimate', 'ngAria', 'ngMaterial', 'ui.router'])

.config(['$stateProvider', function($stateProvider) {
    $stateProvider
      .state("campaigns", {
        url: "/campaigns",
        abstract: true
      })
      .state("campaigns.add", {
        url: "/add",
        onEnter: function($mdDialog) {
          var ev = null; // this should be the $event 
          $mdDialog.show(
            $mdDialog.alert()
            .parent(angular.element(document.body))
            .title('This is an alert title')
            .content('You can specify some description text in here.')
            .ariaLabel('Alert Dialog Demo')
            .ok('Got it!')
            .targetEvent(ev)
          );
        }
      });
  }])
  .controller('myController', function($scope) {

  });


HTML

<div ng-app="myApp" ng-controller="myController"><a ui-sref="campaigns.add">add campaign</a></div>
0

There are 0 answers