Last active
June 3, 2019 12:07
-
-
Save zenius/17b36e7ad45ecaa49de5f6d15ef9ed4f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
If you want to navigate to different pages in your application, but you also want the application to be a SPA (Single Page Application), | |
with no page reloading, you can use the ngRoute module. | |
Applications can only have one ng-view directive, and this will be the placeholder for all views provided by the route. | |
<div ng-view></div> | |
With the $routeProvider you can define what page to display when a user clicks a link. | |
var app = angular.module("myApp", ["ngRoute"]); | |
app.config(function($routeProvider) { | |
$routeProvider | |
.when("/", { | |
templateUrl : "main.htm" | |
}) | |
.when("/london", { | |
templateUrl : "london.htm" | |
}) | |
.when("/paris", { | |
templateUrl : "paris.htm" | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment