更新了一下标签的跳转
This commit is contained in:
parent
fde846f138
commit
1817ea2ca8
|
|
@ -25,6 +25,9 @@ app.config(function($stateProvider, $urlRouterProvider, $httpProvider) {
|
|||
.state('tags', {
|
||||
url: '/tags',
|
||||
templateUrl: '/views/tags.html',
|
||||
params: {
|
||||
tagId: null,
|
||||
},
|
||||
controller: 'tagsCtr'
|
||||
})
|
||||
.state('advice', {
|
||||
|
|
@ -39,8 +42,6 @@ app.config(function($stateProvider, $urlRouterProvider, $httpProvider) {
|
|||
url: '/login',
|
||||
templateUrl: '/views/login.html',
|
||||
params: {
|
||||
foo: null,
|
||||
bar: null,
|
||||
showStyle: 'table',
|
||||
},
|
||||
controller: 'loginCtr'
|
||||
|
|
|
|||
|
|
@ -58,6 +58,12 @@ app.controller('bookmarksCtr', ['$scope', '$state', '$stateParams', '$filter', '
|
|||
toastr.warning('功能暂未实现。。。', "警告");
|
||||
}
|
||||
|
||||
$scope.jumpToTags = function(tagId) {
|
||||
$state.go('tags', {
|
||||
tagId: tagId,
|
||||
})
|
||||
}
|
||||
|
||||
pubSubService.subscribe('EditCtr.inserBookmarsSuccess', $scope, function(event, params) {
|
||||
params.showStyle = $scope.showStyle;
|
||||
console.log('subscribe EditCtr.inserBookmarsSuccess', params);
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
app.controller('tagsCtr', ['$scope', '$filter', '$window', 'bookmarkService', 'pubSubService', function($scope, $filter, $window, bookmarkService, pubSubService) {
|
||||
console.log("Hello tagsCtr...");
|
||||
app.controller('tagsCtr', ['$scope', '$filter', '$window', '$stateParams', 'bookmarkService', 'pubSubService', function($scope, $filter, $window, $stateParams, bookmarkService, pubSubService) {
|
||||
console.log("Hello tagsCtr...", $stateParams);
|
||||
getTags({});
|
||||
|
||||
const perPageItems = 20;
|
||||
$scope.loadBookmarks = false;
|
||||
$scope.tags = []; // 书签数据
|
||||
$scope.bookmarkClicked = false;
|
||||
$scope.bookmarks = [];
|
||||
|
|
@ -10,7 +11,7 @@ app.controller('tagsCtr', ['$scope', '$filter', '$window', 'bookmarkService', 'p
|
|||
$scope.totalPages = 0;
|
||||
$scope.currentPage = 1;
|
||||
$scope.inputPage = '';
|
||||
$scope.currentTagId = "";
|
||||
$scope.currentTagId = ($stateParams && $stateParams.tagId) || '';
|
||||
|
||||
pubSubService.subscribe('MenuCtr.tags', $scope, function(event, data) {
|
||||
console.log('subscribe MenuCtr.tags', data);
|
||||
|
|
@ -20,6 +21,7 @@ app.controller('tagsCtr', ['$scope', '$filter', '$window', 'bookmarkService', 'p
|
|||
$scope.getBookmarks = function(tagId, currentPage) {
|
||||
$scope.bookmarkClicked = true;
|
||||
$scope.currentTagId = tagId;
|
||||
$scope.loadBookmarks = true;
|
||||
|
||||
$scope.tags.forEach(function(tag) {
|
||||
tag.bookmarkClicked = false;
|
||||
|
|
@ -33,15 +35,20 @@ app.controller('tagsCtr', ['$scope', '$filter', '$window', 'bookmarkService', 'p
|
|||
currentPage: currentPage,
|
||||
perPageItems: perPageItems,
|
||||
};
|
||||
|
||||
bookmarkService.getBookmarksByTag(params)
|
||||
.then((data) => {
|
||||
$scope.bookmarks = data.bookmarks;
|
||||
$scope.bookmarkCount = data.totalItems;
|
||||
$scope.totalPages = Math.ceil($scope.bookmarkCount / perPageItems);
|
||||
|
||||
$scope.inputPage = ''
|
||||
$scope.inputPage = '';
|
||||
$scope.loadBookmarks = false;
|
||||
})
|
||||
.catch((err) => console.log('getTags err', err));
|
||||
.catch((err) => {
|
||||
console.log('getTags err', err);
|
||||
$scope.loadBookmarks = false;
|
||||
});
|
||||
};
|
||||
|
||||
$scope.changeCurrentPage = function(currentPage) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<div class="ui container" ng-repeat="tag in bookmarks" ng-init="tagIndex=$index">
|
||||
<div class="ui grid">
|
||||
<div class="row">
|
||||
<div class="wrap" style="width:88px;color:#0aa770;text-align:left;margin-left:20px;">
|
||||
<div class="wrap" style="width:88px;color:#0aa770;text-align:left;margin-left:20px;" ng-click="jumpToTags(tag.id)">
|
||||
<span title="{{ tag.name }}">{{ tag.name }}</span>
|
||||
</div>
|
||||
<div class="fourteen wide column" ng-if="tag.bookmarks.length">
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
<img class="ui ui middle aligned tiny image" ng-src=" http://favicon.byi.pw/?url={{ bookmark.url }}" style="width:16px;height:16px" ng-if="!edit">
|
||||
<span>{{ bookmark.title}}</span>
|
||||
</div>
|
||||
<div class="two wide column js-more-bookmark" ng-class="" ng-mouseover="" ng-mouseleave="" title="查看更多" ng-if="tag.bookmarks.length >= 4">
|
||||
<div class="two wide column js-more-bookmark" ng-class="" ng-mouseover="" ng-mouseleave="" title="查看更多" ng-if="tag.bookmarks.length >= 4" ng-click="jumpToTags(tag.id)">
|
||||
<img class="ui ui middle aligned tiny image" ng-src="./images/more.png" style="width:16px;height:16px">
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
<td>{{ bookmark.created_at }}</td>
|
||||
<td>{{ bookmark.last_click }}</td>
|
||||
<td>
|
||||
<div class="ui label" ng-repeat="tag in bookmark.tags" tag-id="{{ tag.id }}">
|
||||
<div class="ui label" ng-repeat="tag in bookmark.tags" tag-id="{{ tag.id }}" ng-click="jumpToTags(tag.id)">
|
||||
{{ tag.name }}
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -3,14 +3,17 @@
|
|||
<div class="ui grid">
|
||||
<div class="two wide column" ng-class="" ng-mouseover="" ng-mouseleave="" ng-repeat="tag in tags">
|
||||
<div class="ui small label" ng-class="{green:tag.bookmarkClicked}" ng-click="getBookmarks(tag.id, 1)">
|
||||
{{ tag.name }} ({{ tag.cnt }})
|
||||
{{ tag.name }}
|
||||
({{ tag.cnt }})
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table class="ui celled table" ng-if="bookmarkCount > 0">
|
||||
<div class="ui inverted dimmer" ng-class="{active:loadBookmarks, disabled: !loadBookmarks}">
|
||||
<div class="ui huge text loader">正在加载中...</div>
|
||||
</div>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>标题</th>
|
||||
|
|
@ -37,7 +40,7 @@
|
|||
<td>{{ bookmark.created_at }}</td>
|
||||
<td>{{ bookmark.last_click }}</td>
|
||||
<td>
|
||||
<div class="ui label" ng-repeat="tag in bookmark.tags" tag-id="{{ tag.id }}">
|
||||
<div class="ui label" ng-repeat="tag in bookmark.tags" tag-id="{{ tag.id }}" ng-click="getBookmarks(tag.id, 1)">
|
||||
{{ tag.name }}
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
|||
Loading…
Reference in New Issue