title: How to Implement routing based tab navigation swipe using angular js routing?
body: <p>What I hope to do is to implement a swipable navigation based on the Angular-UI--ROUTING and Angular-Material libraries. What I want to accomplish is to be able to swipe on the tabs, if the user wants to change to another one. So if a user swiped where it says "Tab #2" they would be able to move to TAB3 without having to actually click TAB3.</p>
  
  <p>Below is a sample picture of the tabbed navigation that I have created so far:</p>
  
  <p><img src="https://i.stack.imgur.com/S7fjb.png" alt="Angular Routing Material Tabs"></p>
  
  <p>and below is a code snippet or at the <a href="http://codepen.io/dstnation/pen/yyvjvP/" rel="nofollow noreferrer">codepen</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>(function(angular, undefined) {
      "use strict";
      angular.module('dsntApp', ['ngMaterial', "ui.router"])
      .config(function($stateProvider, $urlRouterProvider) {
  
          $urlRouterProvider.otherwise('/tab/dash');
          $stateProvider
          .state('view1', {
              url: "/view1",
              templateUrl: "partials/view1.html"
          })
          .state('view2', {
              url: "/view2",
              templateUrl: "partials/view2.html"
          })
          .state('view3', {
              url: "/view3",
              templateUrl: "partials/view3.html"
          })
          ;
      })
      .controller('tabCtrl', function($scope, $location, $log) {
          $scope.selectedIndex = 0;
  
          $scope.$watch('selectedIndex', function(current, old) {
              switch (current) {
                  case 0:
                      $location.url("/view1");
                      break;
                  case 1:
                      $location.url("/view2");
                      break;
                  case 2:
                      $location.url("/view3");
                      break;
              }
          });
      });
  
  })(angular);</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.intro {
      position: absolute;
      left: 30px;
      top: 20px;
      width: 600px;
      height: 20px;
      font-size : 12px;
  }
  
  .demo {
      position: relative;
      width: 600px;
      height: 300px;
      background-color: #cccccc;
      margin-top: 40px;
      margin-left: 0px;
  }
  
  .demo #content {
      background-color: rgb(255, 255, 255);
      padding: 30px;
      font-weight: 600;
      border: 1px solid #999999;
      border-top: none;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="http://rawgit.com/angular/bower-material/master/angular-material.css" rel="stylesheet"/&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.min.js"&gt;&lt;/script&gt;
  &lt;script src="http://cdnjs.cloudflare.com/ajax/libs/angular-ui-router/0.2.13/angular-ui-router.min.js"&gt;&lt;/script&gt;
  &lt;script src="http://rawgit.com/angular/bower-material/master/angular-material.js"&gt;&lt;/script&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular-aria.js"&gt;&lt;/script&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular-animate.js"&gt;&lt;/script&gt;
  &lt;div class="intro"&gt;
    This demonstration shows how Angular-Material Tabs can be used with Angular-UI-Router
  &lt;div&gt;
    
  &lt;div ng-app="dsntApp" 
       ng-controller="tabCtrl"
       layout="column" class="demo" &gt;
  
    &lt;script type="text/ng-template" id="partials/view1.html"&gt;  Tab #1 &lt;/script&gt;
    &lt;script type="text/ng-template" id="partials/view2.html"&gt;  Tab #2 &lt;/script&gt;
    &lt;script type="text/ng-template" id="partials/view3.html"&gt;  Tab #3 &lt;/script&gt;
    &lt;md-toolbar&gt;
      &lt;h2 class="md-toolbar-tools"&gt;
        &lt;span&gt;Toolbar&lt;/span&gt;
      &lt;/h2&gt;
    &lt;/md-toolbar&gt;
    &lt;md-tabs md-stretch-tabs 
             md-selected="selectedIndex"&gt;
       &lt;md-tab label="tab1"&gt;&lt;/md-tab&gt; 
       &lt;md-tab label="tab2"&gt;&lt;/md-tab&gt;
       &lt;md-tab label="tab3"&gt;&lt;/md-tab&gt;  
    &lt;/md-tabs&gt;
  
    &lt;div id="content" ui-view flex&gt; &lt;/div&gt;
  
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>