我尝试同时使用AngularJS和ASP.NET MVC。 我使用一些页面,例如_layout,changepassword等。 在_layout中,我使用ngRoute来使用SPA之类的页面,到目前为止, 这是我在_layout中的代码和脚本。
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="myApp">
<script type="text/javascript">
var angualarModule1 = angular.module('myApp', ['ngRoute']);
angualarModule1.config(function ($routeProvider) {
debugger;
$routeProvider.when('/firstPage',
{
templateUrl: 'ManageUsers/changepassword',
controller: 'ManageUsersController'
});
});
</script>
<div ng-view>
@RenderBody()
</div>
...
在更改密码页面
@{
Layout = null;
}
<script>
angualarModule1.controller('myCtrl',
function ($scope, $http, $location, $window) {
//******=========Change Password=========******
$scope.saveCustomer = function () {
$scope.result = false;
debugger;
$http({
method: 'POST',
url: '/ManageUsers/ChangePassword',
data: $scope.custModel
}).success(function (data, status, headers, config) {
debugger;
if (data[0] === "success") {
$scope.result = true;
$scope.status = data[0];
$scope.message = data[1];
console.log(data);
} else {
$scope.result = true;
$scope.status = data[0];
$scope.message = data[1];
}
}).error(function (data, status, headers, config) {
$scope.message = 'Unexpected Error while saving data!!' + data.errors;
console.log($scope.message);
});
};
});
运行我的应用程序后,出现错误:[ng:areq]。
这也是我的错误:
angular.js:9997 Error: [ng:areq] http://errors.angularjs.org/1.2.20/ng/areq?p0=ManageUsersController&p1=not%20a%20function%2C%20got%20undefined
at https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js:6:450
at Bb (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js:19:68)
at Ua (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js:19:155)
at https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js:67:405
at link (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular-route.min.js:7:248)
at K (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js:54:390)
at f (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js:47:261)
at https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js:46:377
at https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js:48:217
at w (https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js:52:47) <div ng-view="" class="ng-scope">