Как я могу сделать угловой вызов файла перед загрузкой страницы?
У меня есть _LayoutMaster.cshtml, где я загружаю все файлы JS и angularJS.
<pre> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.19.1/jquery.validate.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/5.4.0/bootbox.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" type="text/javascript"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.0/js/bootstrap.min.js" type="text/javascript"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js" type="text/javascript"></script> <script type="text/javascript" language="javascript" src="//cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css"> <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css"> <link href="~/assets/custom/css/custom.css" rel="stylesheet" type="text/css" /> <link href="https://cdnjs.cloudflare.com/ajax/libs/jasny-bootstrap/4.0.0/css/jasny-bootstrap.min.css" rel="stylesheet" /> <link href="~/assets/css/CommonValidation.css" rel="stylesheet" type="text/css" /> <link href="~/assets/custom/css/custom.css" rel="stylesheet" /> <link href="~/assets/vendors/custom/datatables/datatables.bundle.css" rel="stylesheet" type="text/css" /> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script> <script src="~/ang/config.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap-tpls.min.js"></script> <script src="~/ang/main.ctrl.js"></script> <script src="~/ang/modal.ctrl.js"></script> <script src="~/ang/hr.ctrl.js"></script> <script src="~/ang/Design.ctrl.js"></script> <script src="~/ang/MRM.ctrl.js"></script> <script src="~/ang/Stores.ctrl.js"></script> <script src="~/ang/Admin.ctrl.js"></script>
Теперь у меня есть еще одна страница, где я загружаю страницу макета как -
<pre>@using NtierMvc.Infrastructure @{ ViewBag.Title = "CRM Master"; Layout = "~/Views/Shared/_LayoutMaster.cshtml"; } <link href="~/assets/css/tableStyle.css" rel="stylesheet" /> <link href="~/Content/Site.css" rel="stylesheet" /> <script src="~/Scripts/tabs.js"></script> <div ng-controller="MainController"> <div class="tab"> @if (LocalUtility.CheckUrlForPermission("", "CRM", "CRMMaster", "Customer")) { <button id="defaultOpen" class="tablinks" onclick="openCity(event, 'CustomerPartialView')" ng-click="FetchCustomerList()">Customer</button> }
В этом случае я загружаю частичное представление, где я получаю список как -
<pre><script type="text/javascript"> window.onload = function (){ angular.element(document.getElementById('TblCustomer')).scope('MyController').FetchCustomerList(); } </script>
Что я уже пробовал:
But my problem is my main.ctrl.js file is loading after page load and my function is not calling. Maybe it is hard for me to explain it here. Please feel free for any clarity.