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

时间:2017-04-06 14:17:59

标签: angularjs

我正在调试一个包含各种角度组件的.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);
        }

执行查看 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";

执行看到一个警告框,其中还加载了** Angular IS:object **

然后有一些调查问卷屏幕,最后是“文档上传屏幕”,即感兴趣的屏幕。

   <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>

Angular IS STILL已加载:对象

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

我如何解决这个问题,找出它为什么没有运行? 有没有办法将代码插入到cshtml模板中(而不是在控制器中)直接测试是否加载了角度?

1 个答案:

答案 0 :(得分:0)

是'ui.select'导致角色无声地死去。