Skip to content

Instantly share code, notes, and snippets.

@kaunjovi
Created September 14, 2016 18:30
Show Gist options
  • Save kaunjovi/f00270e4b36d30152167321f91ef2b41 to your computer and use it in GitHub Desktop.
Save kaunjovi/f00270e4b36d30152167321f91ef2b41 to your computer and use it in GitHub Desktop.
AngularJs with route. This example shows vanilla HTML template.
<html>
<head>
<title>Routing with AngularJs</title>
<!--Step 1 : Add the angular js and the angular route-->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular-route.min.js"></script>
</head>
<body ng-app="myApp">
<h1>Routing with AngularJs</h1>
<!--Step 4 : provide a container for route provider to dump it's content in. -->
<div ng-view></div>
</body>
<script>
'use strict' ;
// Step 2 : Create an app and import ngRoute
var app = angular.module("myApp", ['ngRoute']);
// Step 3 : Configure the route. Proivde template HTML that is to be shown on each route.
app.config( function( $routeProvider){
$routeProvider
.when("/", {template : 'Hello world from route provider.'}) ;
}) ;
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment