我刚刚开始使用angularjs并且遇到了路由的概念我正在做一个演示,但它没有工作我不知道我做错了什么请帮助我。我在MVC ASP.NET中这样做
Webapplicatoin3.js
var app = angular.module('WebApplication3', ['ngRoute']);
app.controller('CreateUser1Controller', function ($scope) {
$scope.models = {
helloAngular: 'I workssss!'
};
});
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider.
when('/', {
templateUrl: 'New/CreateUser1'
});
}]);

Home.cshtml
<body ng-app="WebApplication3" ng-controller="CreateUser1Controller">
<div ng-view></div>
<input type="text" ng-model="models.helloAngular" />{{models.helloAngular}}
<script src="~/Scripts/angular.min.js"></script>
<script src="~/Scripts/angular-route.min.js"></script>
<script src="~/Scripts/WebApplication3.js"></script>
</body>
&#13;
CreateUser1.cshtml
<h2>CreateUser1</h2>
<input type="text" ng-model="models.helloAngular" />
<h1>{{models.helloAngular}}</h1>
&#13;
答案 0 :(得分:0)
问题出在WebApplication.js文件中 在templateUrl中,在New
之前添加“/”更新此内容
$routeProvider.
when('/', {
templateUrl: 'New/CreateUser1'
});
到此
$routeProvider.
when('/', {
templateUrl: '/New/CreateUser1'
});