简体   繁体   English

警告:尝试多次加载角度

[英]WARNING: Tried to load angular more than once

i am trying to route in angular.js (1.3.15)and getting these two errors : 我正在尝试在angular.js(1.3.15)中进行路由并遇到以下两个错误:

error messages 错误讯息

 1-WARNING: Tried to load angular more than once. 2-angular.js:38Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=after_login& p1=Err…0d%20(http%3A%2F %2Flocalhost%3A49062%2FScripts%2Fangular.min.js%3A17%3A381) 

my module.js 我的module.js

var after_login = angular.module("after_login", ['ngRoute', 'CrackWeb']);


after_login.config(['$routeProvider', function ($routeProvider) {

  $routeProvider.when('/groups',
                    {
                        templateUrl: 'Views/p1.cshtml',
                        controller: 'MyScripts/groups'
                    })
              .otherwise(
                        {
                            redirectTo: '/'
                        });
$locationProvider.html5Mode(true).hashPrefix('!');
}]);

in my html page with ng-app i have written. 在我用ng-app编写的html页面中。

p1.cshtml [ partial ] p1.cshtml [部分]

<div class="col-md-9">
    <br />
      <input ng-model="check" id="ch"/>
        {{check}}
      <div ng-view></div>
</div>

Can anyone help ? 有人可以帮忙吗?

In your route provider you have mentioned 您在路线提供者中提到

$routeProvider.when('/groups', { templateUrl: 'Views/p1.cshtml', controller: 'MyScripts/groups' }) .otherwise( { redirectTo: '/' });

but you dont have default route 您没有默认路由

$routeProvider.when('/', { templateUrl: 'sometemplate', controller: 'somecontroller' });

so it will try to load your default HTML(most cases index.html) again and again and it cause the error 因此它将尝试一次又一次加载默认的HTML(大多数情况下为index.html),这会导致错误

You can not load a page with cshtml extension! 您无法加载带有cshtml扩展名的页面!

Actually you are wrong when you try to load the page CSHTML through the ANGULAR ROUTING. 实际上,当您尝试通过ANGULAR ROUTING加载页面CSHTML时,您错了。 As you can not load this page alone so well you can not load it through ANGULAR route. 由于您不能单独加载此页面,因此无法通过ANGULAR路由加载该页面。

So if you want to load a page CSHTML then you have to call his controller in MVC and to load it via 'ActionResult'. 因此,如果要加载CSHTML页面,则必须在MVC中调用其控制器,然后通过“ ActionResult”进行加载。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM