ANGULAGJS pages use the route jump
1. In addition to referencing Angularjs.js, also refer to the route JS, "~/scripts/angularjs/angular-route.js"
2. Defining routes through $routeprovider, example
varTestmodule = Angular.module (' Testmodule ', [' Ngroute ']); Testmodule.config ([' $routeProvider ',function($routeProvider) {$routeProvider. When ('/2 ', {//'/2 ' defines a routing path that is later accessed through this path, usually defined as a short pathTemplateurl: "/home/index2",//"/home/index2" is the path to the actual route access, which can be an access path for ASP. NET MVC (in this case), but also a specific page path, such as "test/test.html"Controller: ' TestController '//The controller that routes the jump, which must be defined later }); $routeProvider. When ('/3 ', {templateurl:"/home/index3", Controller:' TestController ' })}]);
3. Use route jump, combine Ng-view to do spa
3.1 Use $location to jump in JS, as an example, call GoToIndex2 when needed
function ($scope, $location) { function () { $location. Path ("/2") }}]);
3.2 Use href= "#path" in HTML code to jump
<HTML><Head> <Metaname= "Viewport"content= "Width=device-width" /> <title>Index1</title>@Styles. Render ("~/content/css/base") @Scripts. Render ("~/script/base")<Scriptsrc= "~/scripts/ngmoudle/app.js"></Script></Head><Body> <DivNg-app= "Testmodule"Ng-controller= "TestController"> <Header> <H1>This is INDEX1</H1> <Buttontype= "button"class= "Btn Btn-default"Ng-click= "GoToIndex2 ()">Index2</Button> <ahref= "#/3"class= "Btn Btn-default">Index3</a><!--Jump by heft= "#path" Way - <ahref= "#/2"class= "Btn Btn-default" >Index2</a> </Header> <DivNg-view> </Div> <Footer>PAGE FOOTER</Footer> </Div></Body></HTML>
Angularjs page Jump route