我一直在网上搜索解决方案,但找不到任何能够解决我的问题的解决方案。 我想用AngularJS和MVC做客户端路由。使用AngularJS和MVC进行路由
这是我使用指导线的Plunker,但它并不能帮助我。我的MVS2项目文件夹结构如下: $ root/Views/Home/Home.html
我得到的错误是找不到页面。我在这里错过了什么?
AngularJS
// create the module and name it myApp
var myApp= angular.module('myApp', ['ngRoute']);
// configure our routes
myApp.config(function ($routeProvider) {
$routeProvider.when('/', {templateUrl: 'Home.html',controller: 'mainController'})
});
// create the controller and inject Angular's $scope
scotchApp.controller('mainController', function ($scope) {
// create a message to display in our view
$scope.message = 'Home Page should appear here';
});
HTML文件的访问
<html data-ng-app="myApp">
<head runat="server">
<title>
<asp:ContentPlaceHolder ID="TitleContent" runat="server" />
</title>
</head
<body data-ng-controller="mainController">
<div id="Div1">
<div data-ng-view></div>
</div>
</body>
</html>
您是否尝试过从浏览器请求Home.html以确定它是否真的被服务? – idursun
我已将该网址复制到我的浏览器,但没有找到它。我不知道如何构建我的路由以获得正确的页面? – Gericke