title: md-selected not working properly in md-tab
body: <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module('tabsDemo', ['ngMaterial']);
  app.controller('TabsController',tabsController);
  function tabsController($scope){
      $scope.showBack = false;
      //$scope.selectedIndex = 3;
      $scope.tabs = [1,2,3,4,5,6];
      $scope.changeTabs = function(){
        $scope.showBack = true;
        $scope.tabs = ['a','b'];
      }
      $scope.goHome = function(){
        $scope.showBack = false;
        $scope.tabs = [1,2,3,4,5,6];
        $scope.selectedIndex = 3;
      }
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link href="https://rawgit.com/angular/bower-material/master/angular-material.css" rel="stylesheet"/&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.6/angular.js"&gt;&lt;/script&gt;
  &lt;script src="https://rawgit.com/angular/bower-material/master/angular-material.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.6/angular-animate.js"&gt;&lt;/script&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.6/angular-aria.js"&gt;&lt;/script&gt;
  &lt;link href="https://fonts.googleapis.com/icon?family=Material+Icons"
        rel="stylesheet"&gt;
        
  &lt;div ng-app="tabsDemo" ng-controller="TabsController"&gt;
  
    &lt;md-button ng-show = "showBack" ng-click = "goHome()"&gt;
     &lt;i class="material-icons"&gt;keyboard_backspace&lt;/i&gt;
    &lt;/md-button&gt;
    
    &lt;md-tabs md-selected="selectedIndex" md-stretch-tabs&gt;
      &lt;md-tab ng-repeat="tab in tabs" label="{{tab}}"&gt;
        &lt;div style="text-align: center;"&gt;
        
           &lt;button ng-bind="tab" ng-click="changeTabs()"&gt;&lt;/button&gt;
              
        &lt;/div&gt;
      &lt;/md-tab&gt;
    &lt;/md-tabs&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>If I assign <code>selectedIndex</code> value directly from controller it is working(changing the tab). If I assign this value from inside a function it is not affecting to the tabs and it setting tab index to zero.</p>