发表于: 2017-04-18 23:44:20
1 1259
今天完成的事情:修复了公司搜索的bug,研究图片上传的angular官方代码
明天计划的事情:做好任务十的样式,学习富文本编辑器的使用
遇到的问题:
一、
第一次加载路由页面时,按钮的样式有问题
刷新就恢复正常样式了:
原因:被跳转之前的登录路由页面的样式覆盖了。路由页面直接用 元素选择器: button{...} ,单独的元素选择器范围太大,这样影响了后面加载的页面。
解决办法:利用类选择器来写,尽量缩小范围,避免影响其他页面。
二、option的空白问题
困扰了4天的bug终于解决了:
用ng-repeat时option会出现空的option,这个很好解决:在前面叫一个value=''的option,使value='?'的空白
消失。
但是在点击搜索后,空的option又回来了:
解决办法:
之前的写法:
<select id="financing" ng-model="financingSelected">
<option value="">全部</option>
<option ng-repeat="(x,y) in financing"
ng-value='x'
ng-selected="financingSelected==x"
>
{{y}}
</option>
</select>
将ng-value='x'改为value={{x}},解决!
<select id="financing" ng-model="financingSelected">
<option value="">全部</option>
<option ng-repeat="(x,y) in financing"
value={{x}}
ng-selected="financingSelected==x"
>
{{y}}
</option>
</select>
原因:很奇怪,可能是angular版本问题。
收获:
图片上传中的指令:
.directive('fileModel', ['$parse', function ($parse) {
//自定义指令,定义一个属性fileModle
return {
restrict: 'A',
//可以简单理解为,当directive被angular 编译后,执行该方法
link: function (scope, element) {
element.bind('change', function (event) {
//srcElement || event.target兼容浏览器
scope.file = (event.srcElement || event.target).files[0];
scope.getFile();
});
}
};
}])
评论