在复杂的 cshtml 应用程序中查找加载的角度



我正在调试一个包含各种角度组件的.cshtml应用程序(razor?)。看起来通过"网络"项目的不同部分中可能有几个角度实例。这不是单页应用。

我的问题不是关于VS/CS,而是关于简单地对应用程序进行逆向工程以查找控制器,模块和应用程序。

问题:我正在处理的屏幕(以下称为"文档上传屏幕")未运行控制器;我的括号 {{}} 显示在屏幕上。

我的故障排除:从主菜单中,应用程序流向"问卷"模块,角度确实被加载:

var appModule = angular.module('cmorApp', ['ngResource', 'ngRoute', 'ngSanitize', 'ngCookies', 'ui.select2', 'ui.utils', 'ui.select', 'ui.bootstrap', 'ui.keypress', 'ui.calendar', 'monospaced.elastic']);
appModule.run(['$rootScope', '$route', '$window', '$http', '$compile', '$cookies', '$location', '$timeout',
function ($rootScope, $route, $window, $http, $compile, $cookies, $location, $timeout) {

if (typeof angular == 'undefined') {
alert("Angular IS loaded: " + typeof angular);
}
else {
alert("Angular is NOT loaded: " + typeof angular);
}

确实看到一个加载了角度IS的警报框:对象

然后它显然加载控制器:

appModule.controller('ReferralCtrl', ['$rootScope', '$scope', '$routeParams', '$http', '$window', '$filter', 'cm.addressService', 'debounce', 'cm.caseService',
function ($rootScope, $scope, $routeParams, $http, $window, $filter, addressService, debounce, caseService) {
if (typeof angular == 'undefined') {
alert("Angular IS also loaded: " + typeof angular);
}
else {
alert("Angular is NOT also loaded: " + typeof angular);
}
$scope.foo = "foo";

确实看到一个警报框,其中还加载了 **角度 IS:对象 **

然后是几个问卷屏幕,最后是"文档上传屏幕",即感兴趣的屏幕。

<div class="section" ng-controller="ReferralCtrl">
{{foo}}
more content

它使用 {{foo}} 呈现更多内容。换句话说,角度似乎没有运行。

并且没有控制台错误。

我已将脚本直接插入页面以测试角度:

<script type="text/javascript">
if (typeof angular == 'undefined') {
alert("Angular IS STILL loaded:  " + typeof angular);
}
else {
alert("Angular IS NOT STILL loaded: " + typeof angular);
}
<div class="section" ng-controller="ReferralCtrl" style="margin-top:30px;">
</div>

确实看到角度仍在加载:对象

那么为什么控制器不工作呢?

如何对此进行故障排除以找出它未运行的原因? 有没有办法将代码插入 cshtml 模板(而不是在控制器中)以直接测试是否加载了角度?

是"ui.select"导致 angular 无声地死去。

最新更新