Visual studio 2015 ngRoute不在Visual Studio 2015中工作

Visual studio 2015 ngRoute不在Visual Studio 2015中工作,visual-studio-2015,ngroute,Visual Studio 2015,Ngroute,我正在尝试使用ngRoute为我在VisualStudio2015中所做的一个项目进行路由。但一旦我将ngRoute放入angular.module,它就会破坏index.html页面的绑定。 有人知道怎么解决吗 我的app.js: var appMainModule = angular.module('appMain', ['ngRoute']); appMainModule.config(function ($routeProvider, $locationProvider) { $rou

我正在尝试使用ngRoute为我在VisualStudio2015中所做的一个项目进行路由。但一旦我将ngRoute放入angular.module,它就会破坏index.html页面的绑定。 有人知道怎么解决吗

我的app.js:

var appMainModule = angular.module('appMain', ['ngRoute']);

appMainModule.config(function ($routeProvider, $locationProvider) {
$routeProvider.when('/', {
    templateUrl: '/Templates/home.html',
    controller: 'homeViewModel'
});

    $routeProvider.otherwise({ redirectTo: '/' });
    $locationProvider.html5Mode(true);
});

appMainModule.controller("indexViewModel", function ($scope, $http, $location) {
     $scope.headingCaption = 'Angular Routing Example';
});

appMainModule.controller("homeViewModel", function($scope, $http, $location){

     $scope.headingCaption = 'This is a list of people:';

    $scope.people = [
        {firstName: 'A', lastName: 'N'}
];

$scope.showPerson = function(person){
    alert('You selected ' + person.firstName + ' ' + person.lastName);
}

});
My index.html:

<!DOCTYPE html>

<html data-ng-app="appMain" data-ng-controller="indexViewModel">
<head>
    <title></title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
</head>
<body>

    <h2>{{headingCaption}}</h2>
    <br />

    <div ng-view></div>

    <script src="scripts/angular.min.js"></script>
    <script src="app/app.js"></script>
    <script src="scripts/angular-route.min.js"></script>

</body>
</html>

{{headingCaption}}

当我只使用时:
var-appMainModule=angular.module('appMain',[])我得到正确的输出。
不带ngRoute的index.html:

但当我放置ngRoute和route Configuration时,页面会转到以下内容: 带有ngRoute的index.html:


提前非常感谢

因此,我通过删除$locationProvider解决了这个问题

appMainModule.config(函数($routeProvider){
…

还删除了:
$locationProvider.html5Mode(true);