Angular JS首页加载问题

huangapple go评论57阅读模式
英文:

Angular js index page loading issue

问题

在加载登录页面时,目前所有控制器都会加载,因此我的系统运行缓慢,因为我在索引文件中附加了所有控制器文件。在加载登录页面时,我需要停止加载不必要的控制器(这些控制器在登录后才需要)。我应该如何停止加载这些控制器,是否需要改变我的结构。

这是我的index.html文件:

<!DOCTYPE html>
<!--[if lt IE 7]>
<html lang="en" ng-app="cacm" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>
<html lang="en" ng-app="cacm" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>
<html lang="en" ng-app="cacm" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html lang="en" ng-app="cacm" class="no-js">
<!--<![endif]-->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title></title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
    <link rel="icon" href="/favicon.ico" type="image/x-icon">

    <link rel="stylesheet" href="lib/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="lib/datatables.net-bs/css/dataTables.bootstrap.min.css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="lib/html5shiv/dist/html5shiv.min.js"></script>
    <script src="lib/respond.js/dest/respond.min.js"></script>
    <script>
        document.createElement('ui-select');
        document.createElement('ui-select-match');
        document.createElement('ui-select-choices');
    </script>
    <![endif]-->

    <!-- Font -->
    <link rel="stylesheet" href="fonts/fonts.css">

    <!-- Custom CSS -->
    <link rel="stylesheet" href="app.css">
</head>

<body class="hold-transition skin-purple fixed sidebar-mini">

    <div class="overlay" id="page-loading-spinner" style="background-color: #ecf0f5">
        <i class="fa fa-spinner fa-spin"
            style="font-size: 26px; position: absolute; top: calc(50% - 13px); left: calc(50% - 13px);"></i>
    </div>
    <script language="javascript" type="text/javascript">
        window.onload = function () {
            document.getElementById('page-loading-spinner').style.display = 'none';
        };
    </script>

    <div ui-view class="main"></div>

    <!-- js libraries -->
    <script src="lib/jquery/dist/jquery.min.js"></script>
    <script src="lib/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="lib/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="lib/datatables-light-columnfilter/dist/dataTables.lightColumnFilter.min.js"></script>
    <script src="lib/chart.js/dist/Chart.min.js"></script>
    <script src="lib/highlightjs/highlight.pack.min.js"></script>
    <script src="lib/chartjs-plugin-labels/build/chartjs-plugin-labels.min.js"></script>
    <script src="lib/jspdf/dist/jspdf.min.js"></script>
    <script src="lib/chartjs-plugin-empty-overlay/dist/chartjs-plugin-empty-overlay.min.js"></script>

    <!-- <script src="lib/datatables-light-columnfilter/distnew/dataTables.lightColumnFilter.min.js"></script> -->
    <script src="lib/datatables-light-columnfilter/distnew/dataTables.lcf.bootstrap3.min.js"></script>

    <!-- angular addons -->
    <script src="lib/angular-ui-select/dist/font-awesome.js"></script>
    <script src="lib/angular/angular.min.js"></script>
    <script src="lib/angular-animate/angular-animate.min.js"></script>
    <script src="lib/angular-ui-router/release/angular-ui-router.min.js"></script>
    <script src="lib/ngstorage/ngStorage.min.js"></script>
    <script src="lib/angular-sanitize/angular-sanitize.min.js"></script>
    <script src="lib/angular-auto-validate/dist/jcs-auto-validate.min.js"></script>
    <script src="lib/angular-datatables/dist/angular-datatables.min.js"></script>
    <script src="lib/angular-datatables/dist/plugins/buttons/angular-datatables.buttons.min.js"></script>
    <script src="lib/angular-datatables/dist/plugins/light-columnfilter/angular-datatables.light-columnfilter.min.js"></script>
    <script src="lib/angular-highlightjs/build/angular-highlightjs.min.js"></script>

    <!-- main app -->
    <script src="app.js"></script>

    <!-- login -->
    <script src="login.js"></script>

    <!-- modules -->
    <script src="modules/category-add/category-add.js"></script>
</body>

</html>

我需要在加载登录页面时停止项目控制器的加载。

英文:

Currently when I load login page, all controllers loading. therefore my system is slow. because I attached all controller files inside the index file. When loading login page i need stop to load unnecessary controllers (that controller need after the login). How I stop this., do i need to change my structure.

this is my index.html

&lt;!DOCTYPE html&gt;
&lt;!--[if lt IE 7]&gt;
&lt;html lang=&quot;en&quot; ng-app=&quot;cacm&quot; class=&quot;no-js lt-ie9 lt-ie8 lt-ie7&quot;&gt; &lt;![endif]--&gt;
&lt;!--[if IE 7]&gt;
&lt;html lang=&quot;en&quot; ng-app=&quot;cacm&quot; class=&quot;no-js lt-ie9 lt-ie8&quot;&gt; &lt;![endif]--&gt;
&lt;!--[if IE 8]&gt;
&lt;html lang=&quot;en&quot; ng-app=&quot;cacm&quot; class=&quot;no-js lt-ie9&quot;&gt; &lt;![endif]--&gt;
&lt;!--[if gt IE 8]&gt;&lt;!--&gt;
&lt;html lang=&quot;en&quot; ng-app=&quot;cacm&quot; class=&quot;no-js&quot;&gt;
&lt;!--&lt;![endif]--&gt;
&lt;head&gt;
&lt;meta charset=&quot;utf-8&quot;&gt;
&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt;
&lt;title&gt;&lt;/title&gt;
&lt;meta content=&quot;width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no&quot; name=&quot;viewport&quot;&gt;
&lt;link rel=&quot;shortcut icon&quot; href=&quot;/favicon.ico&quot; type=&quot;image/x-icon&quot;&gt;
&lt;link rel=&quot;icon&quot; href=&quot;/favicon.ico&quot; type=&quot;image/x-icon&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;lib/bootstrap/dist/css/bootstrap.min.css&quot;&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;lib/datatables.net-bs/css/dataTables.bootstrap.min.css&quot;&gt;
&lt;!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries --&gt;
&lt;!--[if lt IE 9]&gt;
&lt;script src=&quot;lib/html5shiv/dist/html5shiv.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/respond.js/dest/respond.min.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;
document.createElement(&#39;ui-select&#39;);
document.createElement(&#39;ui-select-match&#39;);
document.createElement(&#39;ui-select-choices&#39;);
&lt;/script&gt;
&lt;![endif]--&gt;
&lt;!-- Font --&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;fonts/fonts.css&quot;&gt;
&lt;!-- Custom CSS --&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;app.css&quot;&gt;
&lt;/head&gt;
&lt;body class=&quot;hold-transition skin-purple fixed sidebar-mini&quot;&gt;
&lt;div class=&quot;overlay&quot; id=&quot;page-loading-spinner&quot; style=&quot;background-color: #ecf0f5&quot;&gt;
&lt;i class=&quot;fa fa-spinner fa-spin&quot;
style=&quot;font-size: 26px; position: absolute; top: calc(50% - 13px); left: calc(50% - 13px);&quot;&gt;&lt;/i&gt;
&lt;/div&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;
window.onload = function () {
document.getElementById(&#39;page-loading-spinner&#39;).style.display = &#39;none&#39;;
};
&lt;/script&gt;
&lt;div ui-view class=&quot;main&quot;&gt;&lt;/div&gt;
&lt;!-- js libraries --&gt;
&lt;script src=&quot;lib/jquery/dist/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/bootstrap/dist/js/bootstrap.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/datatables.net/js/jquery.dataTables.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/datatables-light-columnfilter/dist/dataTables.lightColumnFilter.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/chart.js/dist/Chart.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/highlightjs/highlight.pack.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/chartjs-plugin-labels/build/chartjs-plugin-labels.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/jspdf/dist/jspdf.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/chartjs-plugin-empty-overlay/dist/chartjs-plugin-empty-overlay.min.js&quot;&gt;&lt;/script&gt;
&lt;!-- &lt;script src=&quot;lib/datatables-light-columnfilter/distnew/dataTables.lightColumnFilter.min.js&quot;&gt;&lt;/script&gt; --&gt;
&lt;script src=&quot;lib/datatables-light-columnfilter/distnew/dataTables.lcf.bootstrap3.min.js&quot;&gt;&lt;/script&gt;
&lt;!-- angular addons --&gt;
&lt;script src=&quot;lib/angular-ui-select/dist/font-awesome.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/angular/angular.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/angular-animate/angular-animate.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/angular-ui-router/release/angular-ui-router.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/ngstorage/ngStorage.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/angular-sanitize/angular-sanitize.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/angular-auto-validate/dist/jcs-auto-validate.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/angular-datatables/dist/angular-datatables.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/angular-datatables/dist/plugins/buttons/angular-datatables.buttons.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/angular-datatables/dist/plugins/light-columnfilter/angular-datatables.light-columnfilter.min.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;lib/angular-highlightjs/build/angular-highlightjs.min.js&quot;&gt;&lt;/script&gt;
&lt;!-- main app --&gt;
&lt;script src=&quot;app.js&quot;&gt;&lt;/script&gt;
&lt;!-- login --&gt;
&lt;script src=&quot;login.js&quot;&gt;&lt;/script&gt;
&lt;!-- modules --&gt;
&lt;script src=&quot;modules/category-add/category-add.js&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;

I need to stop project controllers, when loading login page

答案1

得分: 1

我认为你必须改变结构代码。

我找到了相同的问题

这里

英文:

I think you must change the structure code.

I found the same question

here

huangapple
  • 本文由 发表于 2023年3月31日 18:33:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75897515.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定