javascript - Angular route not working -


i'm attempting setup basic routes in angular app cannot seem ngview work correctly. below relevant index.html code, module, , config:

index.html:

<body ng-app="myapp">   <h3>testing live</h3>   <div ng-view></div> </body> 

app.module.js:

angular.module('myapp', ['ngroute', 'ngresource']); 

app.config.js:

angular.module('myapp')   .config(function($routeprovider, $locationprovider) {     $routeprovider.when('/player/:playerid',       {         template: '<h1>testing...</h1>',         controller: 'playerinfocontroller',         controlleras: 'playerinfo'         }     );      $locationprovider.html5mode({       enabled: true,       requirebase: false,       rewritelinks: false     });   }); 

when visit /player/56 example, see 'testing live', not 'testing...' expect. instead there's <!-- ngview: --> in section.

i made 2 changes above code working, not understand why necessary; seems "hacky" fix me.

in config file:

$locationprovider.html5mode({   enabled: true,   requirebase: false,   rewritelinks: false }); 

was replaced with:

$locationprovider.html5mode(true); 

and added following head of index.html file:

<base href="/player"> 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -