How to restrict willTransition call when try to attempt transition the same route

If current route is product/new, I am trying to attempt the transition with same route product/new using link-to. In this case will transition called, but I want to restrict this case.

I’ve had this same issue, and I think it’s an area where Ember needs to expose a friendly API.

Here’s a simple check for whether the current route is still part of the target route:

  
willTransition: function(transition) {
  var me = this.routeName;
  if (!transition.handlerInfos.find(function(hi) { return hi.name === me; })) {
    // Really leaving
  }
}

It covers the basic cases: transitioning directly to the current route and transitioning to a child of the current route.

It doesn’t distinguish whether the context for the current route is changing, so going from “/people/1” to “/people/2” would not be considered a “really leaving” situation.