Created
January 12, 2015 21:14
-
-
Save ericpkatz/03a3bb9e391f54b82bd7 to your computer and use it in GitHub Desktop.
Basic Angular // source http://jsbin.com/ruqele
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> | |
<head> | |
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
<meta charset="utf-8"> | |
<title>Basic Angular</title> | |
</head> | |
<body ng-app="app"> | |
<div class="container"> | |
<h4>Angular - Home Page</h4> | |
<div class="well"> | |
<ul> | |
<li><a href="#/">Home</a></li> | |
<li><a href="#/contacts">Contacts</a></li> | |
</ul> | |
</div> | |
<div ng-view></div> | |
</div> | |
<script id="home.html" type="text/ng-template"> | |
<p>{{vm. title}}</p> | |
</script> | |
<script id="contacts.html" type="text/ng-template"> | |
<p>{{ vm.title }}</p> | |
</script> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"></script> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular-route.min.js"></script> | |
<script src="http://code.jquery.com/jquery.min.js"></script> | |
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script> | |
<script id="jsbin-javascript"> | |
angular.module("app", ['ngRoute']); | |
angular.module("app") | |
.controller('HomeCtrl', function($scope){ | |
console.log("Home Ctrl"); | |
var vm = this; | |
vm.title = "Title for Home Page"; | |
}) | |
.controller("ContactsCtrl", function(){ | |
console.log("ContactsCtrl"); | |
var vm = this; | |
vm.title = "Title for Contacts Page"; | |
}); | |
angular.module('app').config(function($routeProvider, $locationProvider){ | |
$routeProvider | |
.when('/', { | |
controller: 'HomeCtrl as vm', | |
templateUrl: 'home.html' | |
}) | |
.when('/contacts', { | |
controller: 'ContactsCtrl as vm', | |
templateUrl: 'contacts.html' | |
}); | |
$locationProvider.html5Mode({ | |
enable: true, | |
requireBase: false | |
}); | |
}); | |
</script> | |
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html> | |
<html> | |
<head> | |
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> | |
<meta charset="utf-8"> | |
<title>Basic Angular</title> | |
</head> | |
<body ng-app="app"> | |
<div class="container"> | |
<h4>Angular - Home Page</h4> | |
<div class="well"> | |
<ul> | |
<li><a href="#/">Home</a></li> | |
<li><a href="#/contacts">Contacts</a></li> | |
</ul> | |
</div> | |
<div ng-view></div> | |
</div> | |
<script id="home.html" type="text/ng-template"> | |
<p>{{vm. title}}</p> | |
<\/script> | |
<script id="contacts.html" type="text/ng-template"> | |
<p>{{ vm.title }}</p> | |
<\/script> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular.min.js"><\/script> | |
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.2/angular-route.min.js"><\/script> | |
<script src="//code.jquery.com/jquery.min.js"><\/script> | |
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"><\/script> | |
</body> | |
</html></script> | |
<script id="jsbin-source-javascript" type="text/javascript">angular.module("app", ['ngRoute']); | |
angular.module("app") | |
.controller('HomeCtrl', function($scope){ | |
console.log("Home Ctrl"); | |
var vm = this; | |
vm.title = "Title for Home Page"; | |
}) | |
.controller("ContactsCtrl", function(){ | |
console.log("ContactsCtrl"); | |
var vm = this; | |
vm.title = "Title for Contacts Page"; | |
}); | |
angular.module('app').config(function($routeProvider, $locationProvider){ | |
$routeProvider | |
.when('/', { | |
controller: 'HomeCtrl as vm', | |
templateUrl: 'home.html' | |
}) | |
.when('/contacts', { | |
controller: 'ContactsCtrl as vm', | |
templateUrl: 'contacts.html' | |
}); | |
$locationProvider.html5Mode({ | |
enable: true, | |
requireBase: false | |
}); | |
});</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
angular.module("app", ['ngRoute']); | |
angular.module("app") | |
.controller('HomeCtrl', function($scope){ | |
console.log("Home Ctrl"); | |
var vm = this; | |
vm.title = "Title for Home Page"; | |
}) | |
.controller("ContactsCtrl", function(){ | |
console.log("ContactsCtrl"); | |
var vm = this; | |
vm.title = "Title for Contacts Page"; | |
}); | |
angular.module('app').config(function($routeProvider, $locationProvider){ | |
$routeProvider | |
.when('/', { | |
controller: 'HomeCtrl as vm', | |
templateUrl: 'home.html' | |
}) | |
.when('/contacts', { | |
controller: 'ContactsCtrl as vm', | |
templateUrl: 'contacts.html' | |
}); | |
$locationProvider.html5Mode({ | |
enable: true, | |
requireBase: false | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment