进行到这里,我们应用开发已经接近尾声,我这里基本就是应用开发的记录过程,讲解的东西很少,有问题可以在评论区讨论呦。下面进入最后调整的阶段。

预览我们的应用,会发现首页的职位列表,也会显示收藏的星星图标,这里我们不需要它:

我们先来进行调整职位列表的组件模块:

positionlist.html:

<span ng-click="$event.stopPropagation();select(item)" ng-if="isFavorite" class="p-a icon {{item.select?'star-active':'star'}}"></span>

这里把是否显示小星星的条件由是否登录改成由其父控制器来控制,打开positionlist.js文件:

'use strict';
angular.module('app').directive('appPositionList',['$http', function($http){
return {
restrict:'A',
replace:true,
templateUrl:'view/template/positionlist.html',
scope:{
data:'=',
filterObj:'=',
isFavorite:'='
},
link:function($scope){
$scope.select = function(item){
$http.post('data/favorite.json',{
id:item.id,
select: !item.select
}).success(function(resp){
item.select = !item.select;
});
};
}
};
}]);

这时,首页的职位列表的收藏图标已经消失了,但是我的收藏的小星星也不见了,而我们在收藏列表里是需要它的:

打开favorite.html文件:

<div app-position-list data="list" is-favorite="true"></div>

现在我们的收藏图标就出现了:

还有首页的头部有一个去登录的按钮和定位的提示语,这是不合逻辑的,当我们是登录状态的时候,应显示用户名称,而在非登录状态显示这两部分,打开head组件部分,head.html:

<div class="head">
<span class="text" ng-hide="name">10秒定制职位</span>
<button class="custom f-r" ng-hide="name" ui-sref="login">去登录</button>
<span class="f-r text" ng-bind="'您好,'+name"></span>
</div>

修改对应的head.js文件:

'use strict';
angular.module('app').directive('appHead',['cache', function(cache){
return{
restrict:'A',
replace:true,
templateUrl:'view/template/head.html',
link:function($scope){
$scope.name = cache.get('name') || '';
}
}
}]);

修改后的效果:

现在进入职位详情页看一下:

我们现在是登录状态,底部显示去登录这不科学,打开positionCtrl.js文件:

'use strict';
angular.module('app')
.controller('positionCtrl', ['$q', '$http', '$state', '$scope','cache', function($q, $http, $state, $scope, cache) {
$scope.isLogin = !!cache.get('name');

此时页面效果如下:

我们想要的页面效果是出来了,但是收藏图标现在还不好使,来处理一下小星星,打开positioninfo.html,给小星星添加一个点击事件:

<img ng-show="isLogin" ng-src="{{imagePath}}" class="p-a" ng-click="favorite();">

然后打开它对应的指令文件positioninfo.js文件:

'use stict';
angular.module('app').directive('appPositionInfo', ['$http', function($http) {
return {
restrict: 'A',
replace: true,
templateUrl: 'view/template/positioninfo.html',
scope: {
isActive: '=',
isLogin: '=',
pos: '='
},
link: function($scope) {
$scope.$watch('pos', function(newValue) {
if(newValue){
$scope.pos.select = $scope.pos.select || false;
$scope.imagePath = $scope.pos.select ? 'image/star-active.png' : 'image/star.png';
}
});
$scope.favorite = function() {
$http.post('data/favorite.json', {
id: $scope.pos.id,
select: !$scope.pos.select
}).success(function(resp){
$scope.pos.select = !$scope.pos.select;
$scope.imagePath = $scope.pos.select ? 'image/star-active.png' : 'image/star.png';
});
};
}
}
}]);

现在我们来完成「投个简历」部分的操作:

打开position.html文件,给底部按钮添加一个点击事件:

<button class="bottom-btn c-w" ng-bind="message" ng-click="go();"></button>

然后打开positionCtrl.js文件来完善逻辑:

'use strict';
angular.module('app')
.controller('positionCtrl', ['$log', '$q', '$http', '$state', '$scope', 'cache', function($log, $q, $http, $state, $scope, cache) {
$scope.isLogin = !!cache.get('name');
$scope.message = $scope.isLogin ? '投个简历' : '去登录'; function getPosition() {
var def = $q.defer();
$http.get('/data/position.json?id=' + $state.params.id).success(function(resp) {
$scope.position = resp;
if (resp.posted) {
$scope.message = '已投递';
}
def.resolve(resp);
}).error(function(err) {
def.reject(err);
});
return def.promise;
}; function getCompany(id) {
$http.get('/data/company.json?id=' + id).success(function(resp) {
$scope.company = resp;
})
}
getPosition().then(function(obj) {
getCompany(obj.companyId);
});
$scope.go = function() {
if ($scope.message != '已投递') {
if ($scope.isLogin) {
$http.post('data/handle.json', {
id: $scope.position.id
}).success(function(resp) {
$log.info(resp);
$scope.message = '已投递';
})
} else {
state.go('login');
} } };
}]);

现在,应用已经修改完毕啦,我们来快速预览一下吧~

10 逻辑完善以及bug修复的更多相关文章

  1. OJ2.0userInfo页面Modify逻辑bug修复,search功能逻辑实现

    这周的主要任务:userInfo页面Modify逻辑bug修复,search功能逻辑实现. (一)Modify逻辑bug修复: 这里存在的bug就是在我们不重置password的时候依照前面的逻辑是不 ...

  2. Flutter实战视频-移动电商-27.列表页_现有Bug修复和完善

    27.列表页_现有Bug修复和完善 小解决小bug 默认右侧的小类没有被加载 数据加载完成后,就list的第一个子对象传递给provide进行赋值,这样右侧的小类就刷新了数据 默认加载了第一个类别 调 ...

  3. 10个JavaScript常见BUG及修复方法

    译者按: JavaScript语言设计太灵活,用起来不免要多加小心掉进坑里面. 原文: Top 10 bugs and their bug fixing 译者: Fundebug 为了保证可读性,本文 ...

  4. 仿酷狗音乐播放器开发日志十九——CTreeNodeUI的bug修复二(附源码)

    转载请说明原出处,谢谢 今天本来打算把仿酷狗播放列表的子控件拖动插入功能做一下,但是仔细使用播放列表控件时发现了几个逻辑错误,由于我的播放 列表控件是基于CTreeViewUI和CTreeNodeUI ...

  5. 微信小程序(有始有终,全部代码)开发---跑步App+音乐播放器 Bug修复

    开篇语 昨晚发了一篇: <简年15: 微信小程序(有始有终,全部代码)开发---跑步App+音乐播放器 > 然后上午起来吃完午饭之后,我就准备继续开工的,但是突然的,想要看B站.然后在一股 ...

  6. Saiku Table展示数据合并bug修复(二十五)

    Saiku Table展示数据合并bug修复 Saiku以table的形式展示数据,如果点击了 非空的字段 按钮,则会自动进行数据合并,为空的数据行以及数据列都会自动隐藏掉. 首先我们应该定位问题: ...

  7. 批量打回未报bug修复

    半天写完了代码,从此开始了三天的bug修复... 问题背景:从合同系统那边获取数据. 1.开发完后,利用mock模拟合同数据,获取(mock中的合同)数据成功,但是在解析合同数据时出错,原因,mock ...

  8. duilib CDateTimeUI 在Xp下的bug修复

    转自:http://my.oschina.net/u/343244/blog/370131 CDateTimeUI 的bug修复.修改CDateTimeWnd的HandleMessage方法 ? 1 ...

  9. windows 10 change default program bug

    windows 10 change default program bug https://www.isumsoft.com/windows-10/how-to-change-or-set-defau ...

随机推荐

  1. 【牛客练习赛 25】A 因数个数和

    题目地址:https://www.nowcoder.com/acm/contest/158/A 参考博客:https://blog.csdn.net/zzcblogs/article/details/ ...

  2. Sphinx排序模式

    目前SPHINX支持6种排序模式.分别是: 1. SPH_SORT_RELEVANCE2. SPH_SORT_ATTR_DESC3. SPH_SORT_ATTR_ASC4. SPH_SORT_TIME ...

  3. terminology(术语)

    1.declaration:告诉编译器某个标识符的name和type,同时略去具体细节. extern int x;     //对象(object)声明式 std::size_t  numDigit ...

  4. 一个关于vue+mysql+express的全栈项目(三)------ 登录注册功能的实现(已经密码安全的设计)

    本系列文章,主要是一个前端的视角来实现一些后端的功能,所以不会讲太多的前端东西,主要是分享做这个项目学到的一些东西,,,,, 好了闲话不多说,我们开始搭建后端服务,这里我们采用node的express ...

  5. 有关OEP脱壳

    首先补充: OEP:(Original Entry Point),程序的入口点,软件加壳就是隐藏了OEP(或者用了假的OEP), 只要我们找到程序真正的OEP,就可以立刻脱壳. PUSHAD (压栈) ...

  6. 杭电 1069 Monkey and Banana

    Description A group of researchers are designing an experiment to test the IQ of a monkey. They will ...

  7. 解决Can’t finish GitHub sharing process Successfully created project ‘GitHubDemo’ on GitHub

    Can't finish GitHub sharing process        Successfully created project 'KeyWordsFrameWork' on GitHu ...

  8. 大数据学习——mapreduce汇总手机号上行流量下行流量总流量

    时间戳 手机号 MAC地址 ip 域名 上行流量包个数 下行 上行流量 下行流量 http状态码 1363157995052 13826544101 5C-0E-8B-C7-F1-E0:CMCC 12 ...

  9. HDU 2462 The Luckiest number

    The Luckiest number Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Ori ...

  10. POJ 2553 The Bottom of a Graph 【scc tarjan】

    图论之强连通复习开始- - 题目大意:给你一个有向图,要你求出这样的点集:从这个点出发能到达的点,一定能回到这个点 思路:强连通分量里的显然都可以互相到达 那就一起考虑,缩点后如果一个点有出边,一定不 ...