我正在开发一个mvc5应用程序(不是spa)但是在我的一个页面中,我创建了一个多步骤表单并选择了angular。如果我刷新页面,一切正常,但是当我点击链接时,我会将我重定向到带有角度的页面,ui-router无法正常工作。
index.chtml
<div class="row" ng-app="formApp">
<!-- views will be injected here -->
<div ui-view></div>
</div>
<script>
require(["angular", "ngAnimate", "ui.router"], function (angular, ngAnimate, router) {
angular.module('formApp', ['ngAnimate', 'ui.router'])
// configuring our routes
// =============================================================================
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
// route to show our basic form (/form)
.state('form', {
url: '/form',
templateUrl: "/AutoAccident/Form",
controller: 'formController'
})
// nested states
// each of these sections will have their own view
// url will be nested (/form/profile)
.state('form.profile', {
url: '/profile',
templateUrl: "/AutoAccident/FormProfile",
})
// url will be /form/interests
.state('form.interests', {
url: '/interests',
templateUrl: "/AutoAccident/FormInterests",
})
// url will be /form/payment
.state('form.payment', {
url: '/payment',
templateUrl: "/AutoAccident/FormPayment",
});
// catch all route
// send users to the form page
$urlRouterProvider.otherwise('/form/profile');
})
// our controller for the form
// =============================================================================
.controller('formController', function ($scope) {
// we will store all of our form data in this object
$scope.formData = {};
// function to process the form
$scope.processForm = function () {
alert('awesome!');
};
});
});
</script>
我的问题是,当我去// mydevurl / AutoAccident / Index触发上面的代码时,我正在
未捕获错误:[$ injector:modulerr] https://docs.angularjs.org/error/ $注射器/ modulerr P0 = formApp&安培; P1 =错误:%20%$ 5B注射器:NOMOD%5D%20http:%2F%2Ferrors.angularjs.org%2F1.4.5%2F $注射器%2Fnomod% 3Fp0%3DformApp%0A%20%20%20%20原子%20Error%20(天然)%0A%20%20%20%20原子%20http:%2F%2Flocalhost:51416个%2FScripts%2Flibs%2Fangular%2Fangular.min。 JS:6:416%0A%20%20%20%20原子%20http:%2F%2Flocalhost:51416个%2FScripts%2Flibs%2Fangular%2Fangular.min.js:24:78%0A%20%20%20%20原子%20A 20%(HTTP:%2F%2Flocalhost:51416个%2FScripts%2Flibs%2Fangular%2Fangular.min.js:23:141)%0A%20%20%20%20原子%20http:%2F%2Flocalhost:51416% 2FScripts%2Flibs%2Fangular%2Fangular.min.js:23:384%0A%20%20%20%20原子%20http:%2F%2Flocalhost:51416个%2FScripts%2Flibs%2Fangular%2Fangular.min.js:37:332 %0A%20%20%20%20原子%20N%20(HTTP:%2F%2Flocalhost:51416个%2FScripts%2Flibs%2Fangular%2Fangular.min.js:7:322)%0A%20%20%20%20原子%20克%20(HTTP:%2F%2Flocalhost:51416个%2FScripts%2Flibs%2Fangular%2Fangular.min.js:37:180)%0A%20%20%20%20原子%20EB%20(HTTP:%2F% 2Flocalhost:51416个%2FScripts%2Flibs%2Fangular%2Fangular.min.js:40:435)%0A%20%20%20%20原子%20D%20(HTTP:%2F%2Flocalhost:51416个%2FScripts%2Flibs%2Fangular%2Fangular.min.js:19:381,
但是当我尝试通过单击浏览器的刷新按钮进行刷新时,应用程序正常工作,我的URI自动变为http://mydevurl/AutoAccident/Index#/form/profile并显示我的多步表单。
单击我的菜单时出现相同的错误。我的多步表单不是我的应用加载时的默认页面。
<li><a href="@Url.Action("Index", "AutoAccident")">Auto Accident</a></li>