我的angularjs应用程序。当我向数据库filtered.length
添加记录时应该增加。
的index.html
<li id="notification_li">
<div ng-init="initFirst(o)" ng-model="o.order_date" ng-repeat="order in filtered = (o|getOrders)" ng-show="filtered.length > 0" ></div>
<span id="notification_count" ng-if="filtered.length > 0">
{{ filtered.length }}
</span>
</div>
</li>
app.js
app.controller('MainCtrl', ['$scope', '$http', '$filter', '$location', 'timeline', 'o', 'routeChecker', 'breadcrumbs', function($scope, $http, $filter, $location, timeline, o, routeChecker, breadcrumbs){
$scope.routeChecker = routeChecker;
$scope.breadcrumbs = breadcrumbs;
$scope.timelineEvent = {};
$scope.o = [];
$scope.init = [];
$scope.timeline = [];
$scope.timelineEvent.contact_date = $filter("date")(Date.now(), 'yyyy-MM-dd');
o.getO(function (o) {
$scope.o = o;
});
$scope.setSelected = function(o) {
$location.path("/clients/" + o.client_id);
};
$scope.initFirst = function(o) {
$http.get('/api.php/contact-timeline')
.success(function(o) {
$scope.o = o;
})
};
}])
它可以工作,但页面加载很长。有什么建议吗?