我有一个页面可以加载大量客户数据。我需要加载的一组子数据是客户端注释。之前的开发人员刚刚将子列表作为主控制器的一部分加载,但我需要能够在其他地方使用用户注释,而不仅仅是主客户端页面的一部分。所以我把所有逻辑都移到了音符控制器上,无论如何我认为它是正确的位置。
但是,我的问题是我的新控制器根本没有执行。
以下是包含所有子视图的主客户端视图。 (主控制器的init执行100%,这是你在这段代码顶部看到的self.init())
<uib-accordion ng-init="self.init()">
<uib-accordion-group is-open="true" heading="Personal Details" panel-class="panel-sm bootstrap-panel accordion-panel">
<div ng-include="'./admin/clients/clientview/personaldetails.html'"></div>
</uib-accordion-group>
<uib-accordion-group heading="Dependants" panel-class="panel-sm bootstrap-panel accordion-panel">
<div ng-include="'./admin/clients/clientview/dependants.html'"></div>
</uib-accordion-group>
<uib-accordion-group heading="Schedules" panel-class="panel-sm bootstrap-panel accordion-panel">
<div ng-include="'./admin/clients/clientview/schedules.html'"></div>
</uib-accordion-group>
<uib-accordion-group heading="Logs" panel-class="panel-sm bootstrap-panel accordion-panel">
<div ng-include="'./admin/clients/clientview/logs.html'"></div>
</uib-accordion-group>
<uib-accordion-group heading="Matches" panel-class="panel-sm bootstrap-panel accordion-panel">
<div ng-include="'./admin/clients/matches/suggestions.html'"></div>
</uib-accordion-group>
<uib-accordion-group heading="Documents" panel-class="panel-sm bootstrap-panel accordion-panel">
<div ng-include="'./admin/clients/clientview/documents.html'"></div>
</uib-accordion-group>
<uib-accordion-group heading="User Notes" panel-class="panel-sm bootstrap-panel accordion-panel">
**<div ng-include="'./admin/usernotes/usernotes.html'"></div>**
</uib-accordion-group>
</uib-accordion>
最下面一个是我的新笔记视图。 在我看来它看起来像这样:(我已经尝试将ng-controller和ng-init移动到上面的div而没有成功)
<div ba-panel ng-controller="UserNotesController" ng-init="self.init()">
...
</div>
第二个控制器init根本没有执行。 (我没有包括整个控制器)
(function () {
'use strict';
angular.module('Common.services')
.controller('UserNotesController', UserNotesController);
/** @ngInject */
function UserNotesController(fileReader, $scope, UserNotes, Loader, toastr, $uibModal) {
var self = this;
...
function init() {
self.GetUserNotes(); debugger;
}
}
})();
没有任何错误。 (添加了调试器;看它是否执行) 用户注释正在显示视图,但控制器未在执行。
知道我做错了吗?