我想我已经尝试过所有可能的解决方案。
问题是当我在M.E.A.N App中的页面之间移动时,范围没有将功能连接到范围,或者没有将新数据作为数组引入范围,除非我刷新。
我真的不知道是什么问题。
可能是使用$ rootscope或其他东西的localStorage,但每次我尝试编写$ scope.apply时,我都会得到“摘要已经在进行中”错误。 当我和$ timeout一起使用申请时,没有任何事情发生。
以下是该应用的链接:http://sce.edpcloud.co.il/login 用户名:哈达斯 密码:123abc
登录时,单击框中的某个链接,然后返回主页面。除非您刷新,否则不会显示框中的项目。
这是脚本:
lecturerNavigateModule.controller('dashboardController', function ($scope, $window, $http,$timeout, Projects, $filter,localStorageService) {
var curProjects = {};
$scope.projectsData ={};
jQuery(document).ready(function() {
// initiate layout and plugins
App.init(); // init metronic core components
Layout.init(); // init current layout
QuickSidebar.init(); // init quick sidebar
Demo.init(); // init demo features
});
$scope.numOfMyProject = -1;
console.log("123")
/*
* User details from session in order to use them in server queries
*/
var curUserID = "5718790f07176aa8cd7a4d95";//localStorageService.get('userId');
Projects.getByLecturer(curUserID)
.success(function (data) {
curProjects = data;
$scope.projectsData = data;
$scope.numOfMyProject = data.length;
$scope.numOfKolKore = data.filter(function (proj) { return proj.curState.curStatus =='קול קורא'; }).length;
$scope.numOfWaiting = data.filter(function (proj) { return proj.curState.curStatus =='ממתין לאישור'; }).length;
$scope.numOfProccess = data.filter(function (proj) { return proj.curState.curStatus =='בביצוע'; }).length;
$scope.numOfGrouped = data.filter(function (proj) { return proj.curState.curStatus =='ניסוח הצעה'; }).length;
});
$scope.showProject = function (project) {
console.log(project._id)
location.href = '#/project/' + project._id;
};
$scope.$watch('search', function(val)
{
var items = $filter('filter')(curProjects, val);
$scope.projectsData = items;
});
});
<div class="page-content">
<!-- BEGIN PAGE HEADER-->
<!-- BEGIN PAGE TITLE-->
<h3 class="page-title">דשבורד
<small>סקירת מצב</small>
</h3>
<!-- END PAGE TITLE-->
<!-- END PAGE HEADER-->
<div class="row widget-row">
<div class="col-md-3">
<!-- BEGIN WIDGET THUMB -->
<div class="widget-thumb widget-bg-color-white text-uppercase margin-bottom-20 bordered">
<h4 class="widget-thumb-heading">קול קורא</h4>
<div class="widget-thumb-wrap">
<i class="widget-thumb-icon bg-green icon-bulb"></i>
<div class="widget-thumb-body">
<span class="widget-thumb-body-stat">{{numOfKolKore}}</span>
</div>
</div>
</div>
<!-- END WIDGET THUMB -->
</div>
<div class="col-md-3">
<!-- BEGIN WIDGET THUMB -->
<div class="widget-thumb widget-bg-color-white text-uppercase margin-bottom-20 bordered">
<h4 class="widget-thumb-heading">מצוותים
<!--<small class="small-color-as-h3"> ממתינים לציון</small>-->
</h4>
<div class="widget-thumb-wrap">
<i class="widget-thumb-icon bg-yellow-soft icon-layers"></i>
<div class="widget-thumb-body">
<span class="widget-thumb-body-stat">{{numOfGrouped}}</span>
</div>
</div>
</div>
<!-- END WIDGET THUMB -->
</div>
<div class="col-md-3">
<!-- BEGIN WIDGET THUMB -->
<div class="widget-thumb widget-bg-color-white text-uppercase margin-bottom-20 bordered">
<h4 class="widget-thumb-heading">ממתינים לאישור</h4>
<div class="widget-thumb-wrap">
<i class="widget-thumb-icon bg-red icon-pencil"></i>
<div class="widget-thumb-body">
<span class="widget-thumb-body-stat">{{numOfWaiting}}</span>
</div>
</div>
</div>
<!-- END WIDGET THUMB -->
</div>
<div class="col-md-3">
<!-- BEGIN WIDGET THUMB -->
<div class="widget-thumb widget-bg-color-white text-uppercase margin-bottom-20 bordered">
<h4 class="widget-thumb-heading">בפעולה</h4>
<div class="widget-thumb-wrap">
<i class="widget-thumb-icon bg-green-jungle icon-energy"></i>
<div class="widget-thumb-body">
<span class="widget-thumb-body-stat">{{numOfProccess}}</span>
</div>
</div>
</div>
<!-- END WIDGET THUMB -->
</div>
</div>
<div class="row">
<div class="col-md-6 col-sm-6">
<div class="portlet light ">
<div class="portlet-title">
<div class="caption caption-md">
<i class="icon-bar-chart font-dark hide"></i>
<span class="caption-subject font-dark bold">הפרויקטים שלי</span>
<small>{{numOfMyProject}} פרויקטים</small>
</div>
<div class="inputs">
<div class="portlet-input input-inline input-small ">
<div class="input-icon right">
<i class="icon-magnifier"></i>
<input type="text" class="form-control form-control-solid input-circle"
placeholder="חפש..." ng-model="search"></div>
</div>
</div>
</div>
<div class="portlet-body">
<div class="scroller" style="height: 338px;" data-always-visible="1" data-rail-visible1="0"
data-handle-color="#D7DCE2">
<div class="general-item-list">
<div class="item" ng-repeat="project in projectsData">
<div class="item-head">
<div class="item-details">
<img class="item-pic rounded" src="{{project.picUrl}}">
<a href="account/lecturer/project/{{project._id}}"
class="item-name primary-link">{{project.nameHeb}}</a>
<!--span class="item-label">5 hrs ago</span>-->
</div>
<span class="item-status">
<span class="badge badge-empty badge-warning"></span>
{{project.curState.curStage}}
</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
UPDATE 01062016 17:58 1.当我在get函数后插入apply时,我收到“正在进行摘要”错误。 2.当我插入最新版本的angular(1.5.6)并在页面之间移动(进入项目并按“后退”)时,我得到下一个错误:“TypeError:无法读取未定义的属性'parent'”
Projects.getByLecturer(curUserID)
.success(function (data) {
curProjects = data;
$scope.projectsData = data;
}).then(function(data) {
$scope.$apply();
});
angular.js:13642 Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.5.6/$rootScope/inprog?p0=%24digest
at angular.js:68
at beginPhase (angular.js:17738)
at Scope.$apply (angular.js:17476)
at controller.navigate.lecturer.js:35
at processQueue (angular.js:16104)
at angular.js:16120
at Scope.$eval (angular.js:17378)
at Scope.$digest (angular.js:17191)
at Scope.$apply (angular.js:17486)
at done (angular.js:11637)(anonymous function) @ angular.js:13642(anonymous function) @ angular.js:10287Scope.$apply @ angular.js:17483(anonymous function) @ controller.navigate.lecturer.js:35processQueue @ angular.js:16104(anonymous function) @ angular.js:16120Scope.$eval @ angular.js:17378Scope.$digest @ angular.js:17191Scope.$apply @ angular.js:17486done @ angular.js:11637completeRequest @ angular.js:11843requestLoaded @ angular.js:11776
angular.js:13642 Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.5.6/$rootScope/inprog?p0=%24digest
at angular.js:68
at beginPhase (angular.js:17738)
at Scope.$digest (angular.js:17168)
at Scope.$apply (angular.js:17486)
at controller.navigate.lecturer.js:35
at processQueue (angular.js:16104)
at angular.js:16120
at Scope.$eval (angular.js:17378)
at Scope.$digest (angular.js:17191)
at Scope.$apply (angular.js:17486)(anonymous function) @ angular.js:13642(anonymous function) @ angular.js:10287Scope.$apply @ angular.js:17488(anonymous function) @ controller.navigate.lecturer.js:35processQueue @ angular.js:16104(anonymous function) @ angular.js:16120Scope.$eval @ angular.js:17378Scope.$digest @ angular.js:17191Scope.$apply @ angular.js:17486done @ angular.js:11637completeRequest @ angular.js:11843requestLoaded @ angular.js:11776
angular.js:13642 Error: [$rootScope:inprog] $digest already in progress
http://errors.angularjs.org/1.5.6/$rootScope/inprog?p0=%24digest
at angular.js:68
at beginPhase (angular.js:17738)
at Scope.$digest (angular.js:17168)
at Scope.$apply (angular.js:17486)
at controller.navigate.lecturer.js:35
at processQueue (angular.js:16104)
at angular.js:16120
at Scope.$eval (angular.js:17378)
at Scope.$digest (angular.js:17191)
at Scope.$apply (angular.js:17486)