Skip to content

Instantly share code, notes, and snippets.

@e-oz
Created July 22, 2015 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save e-oz/94bbffdf115187272dd3 to your computer and use it in GitHub Desktop.
Save e-oz/94bbffdf115187272dd3 to your computer and use it in GitHub Desktop.
Material Tabs & hRefs
<div class="intro">
<a target="_blank" href="https://github.com/angular/material/issues/3243">https://github.com/angular/material/issues/3243</a>
<br/>To see an issue, please open development console (with "console" tab opened) and click "Login" then "Home".
<br/>
Only first tab use ng-click there and it's intended - to show how it works without ng-click.
<div>
<div ng-app="demoApp"
ng-controller="DemoController as cNav"
layout="column" class="demo" >
<script type="text/ng-template" id="partials/view1.html"> View #1 </script>
<script type="text/ng-template" id="partials/view2.html"> View #2 </script>
<script type="text/ng-template" id="partials/view3.html"> View #3 </script>
<md-tabs class="md-primary" md-autoselect="false" md-no-pagination="false" md-center-tabs="false">
<md-tab label="Home" ng-click="cNav.go('/view1')" md-active="cNav.state == '/view1'"></md-tab>
<md-tab label="Login" md-on-select="cNav.go('/view2')" md-active="cNav.state == '/view2'"></md-tab>
<md-tab label="Activity" md-on-select="cNav.go('/view3')" md-active="cNav.state == '/view3'"></md-tab>
</md-tabs>
<div id="content" ng-view flex> </div>
</div>
(function(angular, undefined){
"use strict";
angular.module('demoApp', ['ngMaterial', "ngRoute"])
.config(["$routeProvider", function($routeProvider) {
$routeProvider.when("/view1", {templateUrl: "partials/view1.html"});
$routeProvider.when("/view2", {templateUrl: "partials/view2.html"});
$routeProvider.when("/view3", {templateUrl: "partials/view3.html"});
$routeProvider.otherwise({redirectTo: "/view1"});
}])
/**
* Simple controller to build a `user` data model
* that will be used to databinding with `<tf-float>` directives
*/
.controller('DemoController',function($location){
this.state =$location.path();
this.go=function(path){
$location.path(path);
};
});
})(angular);
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.js"></script>
<script src="http://rawgit.com/angular/bower-material/master/angular-material.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-route.js"></script>
body {
position:relative;
}
.intro {position:absolute;
left:30px;
top:20px;
width : 600px;
height: 20px;
}
.demo {
position:relative;
width : 600px;
height : 300px;
background-color: #aeaeae;
margin-top:40px;
margin-left:0px;
}
.demo a {
text-decoration: none !important;
color: white;
height:100%;
width:100%;
}
.demo a.visited {
color:white;
}
.demo #content {
background-color: rgb(255, 244, 220);
padding:30px;
font-weight:600;
border: 1px solid #aeaeae;
border-top:none;
}
<link href="http://rawgit.com/angular/bower-material/master/angular-material.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment