title: What is the difference between attachMatched() and attachPatternMatched() and/or attachRouteMatched() and attachRoutePatternMatched() in SAPUI5?
body: <p>Would be happy about an example of what is the difference between the following SAPUI5 routing approaches:</p>
  
  <p><strong><code>sap.ui.core.routing.Route</code></strong>:</p>
  
  <ul>
  <li><code>attachMatched()</code></li>
  <li><code>attachPatternMatched()</code></li>
  </ul>
  
  <p><strong><code>sap.ui.core.routing.Router</code></strong>:</p>
  
  <ul>
  <li><code>attachRouteMatched()</code></li>
  <li><code>attachRoutePatternMatched()</code></li>
  </ul>
  
  <p>API says for <code>attachMatched()</code> and <code>attachPatternMatched()</code> nothing about any difference.</p>
  
  <p>API says for <code>attachRouteMatched()</code>:</p>
  
  <blockquote>
    <p>Attach event-handler <code>fnFunction</code> to the <code>routeMatched</code> event of this
    <code>sap.ui.core.routing.Router</code>.</p>
  </blockquote>
  
  <p>API says for <code>attachRoutePatternMatched()</code>:</p>
  
  <blockquote>
    <p>Attach event-handler <code>fnFunction</code> to the <code>routePatternMatched</code> event of
    this <code>sap.ui.core.routing.Router</code>. This event is similar to route
    matched. But it will only fire for the route that has a matching
    pattern, not for its parent <code>Routes</code>.</p>
  </blockquote>
  
  <p>E.g. could use</p>
  
  <pre class="lang-js prettyprint-override"><code>sap.ui.define([
      "sap/ui/core/mvc/Controller"
  ], function (Controller) {
      "use strict";
      return Controller.extend("sap.ui.demo.wt.controller.Detail", {
          onInit: function () {
              var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
              oRouter.getRoute("detail").attachMatched(this._onObjectMatched, this);              
              // oRouter.attachRouteMatched(this._onObjectMatched, this);
          },
          _onObjectMatched: function (oEvent) {
              this.getView().bindElement({
                  path: "/" + oEvent.getParameter("arguments").invoicePath,
                  model: "invoice"
              });
          }
      });
  });
  </code></pre>
  
  <p>or</p>
  
  <pre class="lang-js prettyprint-override"><code>sap.ui.define([
      "sap/ui/core/mvc/Controller"
  ], function (Controller) {
      "use strict";
      return Controller.extend("sap.ui.demo.wt.controller.Detail", {
          onInit: function () {
              var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
              oRouter.getRoute("detail").attachPatternMatched(this._onObjectMatched, this);
              // oRouter.attachRoutePatternMatched(this._onObjectMatched, this);
          },
          _onObjectMatched: function (oEvent) {
              this.getView().bindElement({
                  path: "/" + oEvent.getParameter("arguments").invoicePath,
                  model: "invoice"
              });
          }
      });
  });
  </code></pre>
  
  <p>No difference to see. Don't get «But it will only fire for the route that has a matching pattern, not for its parent Routes.» Thought <code>attachRouteMatch()</code> would fire only as well for the route that has a matching pattern.</p>