0

I am using AngularJS and when I began to use routeprovider, if I reload the page occur a infinite load.

It's funny, because when I try to load the main page the first time, the page starts fine.

Here is my code:

var app = angular.module("platwip", []);

app.config(['$routeProvider', function($routeProvider) {
    $routeProvider.
    when('/status', {templateUrl: 'resources/views/html_files/status/status.dust',   controller: TestCtrl}).
    when('/network/wan', {templateUrl: '/resources/viewsAngular/network/wanAngular.html', controller: WanCtrl}).        
    otherwise({redirectTo: '/status'});
 }]);

 app.run(function($templateCache,$http){
    $http.get('resources/viewsAngular/menus/sideMenu.html', {cache:$templateCache});
    $http.get('resources/viewsAngular/menus/topMenu.html', {cache:$templateCache});
 });

My Html:

<!DOCTYPE html>
<html ng-app="platwip">
<head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
    <link media="screen" type="text/css" rel="stylesheet" href="/resources/css/estilo.css"></link>
    <script src="/resources/js/jquery/jquery-1.8.1.min.js" ></script>
    <script src="/resources/js/jquery/jquery.i18n.min.js" ></script>
    <script src="/src/controller/main/main.ws/messages" ></script>
    <script src="/resources/js/jquery/jquery-ui-1.8.23.custom.min.js" ></script>
    <script src="/resources/js/jquery/jquery.input-ip-address-control-1.0.min.js" ></script>
    <script src="/resources/js/jquery/jquery.date.format.js" ></script>
    <script src="/resources/js/jquery/jquery.address-1.5.min.js" ></script>
    <script src="/resources/js/jquery/jquery.maskedinput-1.3.min.js" ></script>
    <script src="/resources/js/jquery/jquery.validate.min.js" ></script>
    <script src="/resources/js/validator_rules.js" ></script>
    <script src="/resources/js/jquery/jquery.tablesorter.min.js" ></script>
    <script src="/resources/js/angular/angular.min.js" ></script>
    <script src="/resources/js/angular/controllers.js" ></script>
    <script src="/resources/js/angular/partials.js" ></script>
    <script src="/resources/js/angular/filters.js" ></script>
    <script src="/resources/js/dust/dust-full-1.2.0.js" ></script>
    <script src="/resources/js/dust/dust-helpers-1.1.1.js" ></script>
    <script src="/resources/js/main.js" ></script>

</head>
<body>
        <!-- <div id="qunit"></div>
        <div id="qunit-fixture"></div> -->
        <div id="container">
            <div id="cabecalho">
                <div id="barraSuperior"></div>
                <div id="menuSuperior" ng-include src="'resources/viewsAngular/menus/topMenu.html'"/>
                </div>
            </div>
            <noscript >
                {{'Ops!! Seu navegador não está com o JavaScript habilitado. Para utilizar a aplicação você deve habilitar o JavaScript.' | i18n}}
                <style type="text/css">
                #conteudo { display:none; }
                </style>
            </noscript>
            <div id="conteudo">
                <div id="menuLateral" ng-include src="'resources/viewsAngular/menus/sideMenu.html'">
                </div>
                <div class="content">
                    <div id="titulo">
                        <h1></h1>
                    </div>
                    <div id='conteudoWeb' ng-view>

                        <div class='tab'>

                        </div>

                    </div>
                </div>
                <div class="clear"></div>                   
            </div>
        </div>
    </body>
    </html>

Has somebody an idea what is the problem?

Thank you!

4

1 回答 1

1

解决了。

我有一个 JS 文件(main.js),它有一个函数,它在我的应用程序中循环加载。在我放置 Angular 之后,选择器变量每次都在变化。

功能是:

var browserHistory = function(){
    $.address.init().change(function(event){
        var selector = "[rel='address:" + event.value + "']";
        var link = $(selector);         
        if(link.length > 0)
            loadContent(link);
        else
            $.address.value("/");
    });

};

坝。

再见!

于 2013-04-16T14:52:40.623 回答