Created
March 6, 2015 21:07
-
-
Save LoganArnett/be94859ff2bc7df32cb1 to your computer and use it in GitHub Desktop.
Basic Routing Demo for UI-Router
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
angular.module('routeApp') | |
.controller('AnoCtrl', function(){ | |
console.log('Goodbye'); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section id="another"> | |
<div class="another-content"> | |
<h1 class="awesome-header">AwesomeSauce Header</h1> | |
<ul class="another-list"> | |
<li class="another-item">Item 1</li> | |
<li class="another-item">Item 2</li> | |
<li class="another-item">Item 3</li> | |
<li class="another-item">Item 4</li> | |
<li class="another-item">Item 5</li> | |
</ul> | |
<a href="/main"> | |
<h4>link back to main</h4> | |
</a> | |
<a href="/main/list"> | |
<h4>link back to main.list</h4> | |
</a> | |
<a href="/main"> | |
<h4>link back to main</h4> | |
</a> | |
</div> | |
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
angular.module('routeApp', ['ui.router']) | |
.config(function($stateProvider, $urlRouterProvider){ | |
$stateProvider | |
.state('main', { | |
url: '/main', | |
templateUrl: 'views/main.html' | |
}) | |
.state('main.list', { | |
url: '/list', | |
templateUrl: '../views/main.list.html' | |
}) | |
.state('main.image', { | |
url: '/image', | |
templateUrl: '../views/main.img.html' | |
}) | |
.state('another', { | |
url: '/another', | |
templateUrl: 'views/another.html', | |
controller: 'AnoCtrl', | |
controllerAs: 'ano' | |
}) | |
$urlRouterProvider.otherwise('/main'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Install Angular UI Router or NgRoute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" ng-app="routeApp"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Route Demo</title> | |
</head> | |
<body ng-controller="MainCtrl as app"> | |
<div ui-view></div> | |
<script src="bower_components/angular/angular.js"></script> | |
<script src="bower_components/ui-router/release/angular-ui-router.js"></script> | |
<script src="app.js"></script> | |
<script src="controllers/main.controller.js"></script> | |
<script src="controllers/ano.controller.js"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
angular.module('routeApp') | |
.controller('MainCtrl', function(){ | |
console.log('Hello World'); | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section id="main"> | |
<div class="main-content"> | |
<h3>This is a List</h3> | |
<div ui-view></div> | |
<a href="/another"> | |
<h4>this is a link to a new route</h4> | |
</a> | |
<a href="/main/list"> | |
<h4>link back to main.list</h4> | |
</a> | |
<a href="/main"> | |
<h4>link back to main</h4> | |
</a> | |
<a href="/main/image"> | |
<h4>link back to main image</h4> | |
</a> | |
</div> | |
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section class="images"> | |
<figure> | |
<img src="http://www.thirstyforbeer.com/db/wp-content/uploads/2013/05/ThirstyForBeer_AwesomeGIFs-0011.gif" alt="Nice"> | |
<figcaption>AwesomePhoto</figcaption> | |
</figure> | |
</section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul class="random-list"> | |
<li class="list-item">Item 1</li> | |
<li class="list-item">Item 2</li> | |
<li class="list-item">Item 3</li> | |
<li class="list-item">Item 4</li> | |
<li class="list-item">Item 5</li> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment