Skip to content

Instantly share code, notes, and snippets.

@omniosi
Created September 2, 2016 00:01
Show Gist options
  • Save omniosi/d474f3ee0382705407237eda5f365096 to your computer and use it in GitHub Desktop.
Save omniosi/d474f3ee0382705407237eda5f365096 to your computer and use it in GitHub Desktop.
angular1-router-states
<h3>Its the UI-Router hello world app!</h3>
var myApp = angular.module('helloworld', ['ui.router']);
myApp.config(function($stateProvider){
var helloState = {
name: 'hello',
url: '/hello',
template: '<h3>hello world!</h3>'
}
var aboutState = {
name: 'about',
url: '/about',
// template: '<h3>Its the UI-Router hello world app!</h3>'
templateUrl: 'about.html'
}
$stateProvider.state(helloState);
$stateProvider.state(aboutState);
});
<html>
<head>
<script src="lib/angular.js"></script>
<script src="lib/angular-ui-router.js"></script>
<script src="helloworld.js"></script>
<style>
.active{
color: red;
font-weight: bolder;
}
</style>
</head>
<body ng-app="helloworld">
<a ui-sref="hello" ui-sref-active="active">Hello</a>
<a ui-sref="about" ui-sref-active="active">About</a>
<ui-view></ui-view>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment