更新了这么久,前段时间一直没有写博客的冲动!昨天和老师聊了好多东西,感觉是应该坚持写博客了!好了,废话少说了,继续写!!
bower install underscore --save说明: 使用--save参数,安装的时候,就会自动将安装的underscore写入到bower.json中,而不需要手动来添加,同样,在使用npm管理工具的使用,一样的有这个参数
<!-- bower:js --> <script src="/bower_components/underscore/underscore.js"></script> <script src="bower_components/jquery/jquery.js"></script> <script src="bower_components/angular/angular.js"></script> <script src="bower_components/json3/lib/json3.js"></script> <script src="bower_components/bootstrap/docs/assets/js/bootstrap.js"></script> <script src="bower_components/angular-resource/angular-resource.js"></script> <script src="bower_components/angular-cookies/angular-cookies.js"></script> <script src="bower_components/angular-sanitize/angular-sanitize.js"></script> <script src="bower_components/angular-animate/angular-animate.js"></script> <script src="bower_components/angular-touch/angular-touch.js"></script> <script src="bower_components/angular-route/angular-route.js"></script> <!-- endbower -->
npm install grunt-contrib-jade --save-dev这里我们使用这条命令,就能够安装jade模板引擎,同时添加进package.json.
BidResult.sort_by_price=function (bid_name){ return _.sortBy(Bid.find_clicked_bid_messages(bid_name), function (list) { return list.price; }) };
BidResult.bid_success_user = function (argument){ var count_price = _.groupBy(argument,function(obj){ return obj.price; }); BidResult.save_bid_count_price_user(count_price); return _.find(count_price,function(price){ return price.length==1 }); };
BidResult.save_bid_count_price_user=function(argument){ var result = _.map(argument, function(value,key ){ return {"price": key, "count": value.length} }); localStorage['bid_result'] = JSON.stringify(result); };这里,我们使用underscore的map方法,将按照价格排序之后的数组,通过map重新组合成新的对象,
header.header | {{current_bid}} ({{bid_user_num}}人) button.btn.btn-primary.header-left(ng-show='true', ng-click='back_to_bid_list_page()') 返回 button.btn.btn-primary.header-right(ng-show='true', ng-disabled='button_enable', ng-click='\ back_to_bid_result_page()') 列表 #wrapper.wrapper ul.list-style-2 li.clearfix.btn-default(ng-repeat='bid in bidcounts track by $index', ng-click='choose_bid(bid)') h3 ¥{{bid.price}} i {{bid.count}}人 footer div(ng-show='success_bid') h5 | 竞价结果:{{success_user.name}} ¥{{success_user.price}} {{success_user.phone.slice(0,3)}}XXXX{{success_user.phone.slice(7)}} div(ng-show='fail_bid') h5 | 竞价失败这里,我们使用了jade模板引擎,同样,使用angular的ng-repeat标签显示出结果数组
<link rel="stylesheet" href="bower_components/bootstrap/docs/assets/css/bootstrap.css" />同时,我们还应该如入bootstrapjs和jqueryjs
<script src="bower_components/jquery/jquery.js"></script> <script src="bower_components/bootstrap/docs/assets/js/bootstrap.js"></script>这里,,特别说明一下,还需要引入一个样式,我之前就因为少引入了一个样式库,然后花了很多的时间来解决后面的问题
<link rel="stylesheet" href="bower_components/bootstrap/docs/assets/css/bootstrap-responsive.css" />bootstrap-responsive.css是必须引入的,只有引入了这个库,才能够自动换行,能改自动适应浏览器,这可能就是他们所说的响应式布局吧?
#example.modal.hide.fade(tabindex='-1', role='dialog', aria-labelledby='myModalLabel', aria-hidden='true') .modal-header a.close(data-dismiss='modal', ng-click='show_footer_by_button()') × h3 竞价结果 .modal-body(ng-show='modal_disp') h4 {{success_user.name}}¥{{success_user.price}} p {{success_user.phone.slice(0,3)}}XXXX{{success_user.phone.slice(7)}} .modal-body p {{is_bid_success}} footer div(ng-show='show_success_user') h5 | 竞价结果:{{success_user.name}}¥{{success_user.price}}{{success_user.phone.slice(0,3)}}XXXX{{success_user.phone.slice(7)}} div(ng-show='show_fail_user') h5 | 竞价失败
$('#example').modal("show"); $timeout(function () { $('#example').modal('hide'); $scope.show_success_user=BidResult.is_bid_success(bid_success_user); $scope.show_fail_user= BidResult.is_bid_fail(bid_success_user); }, 3000);
因为这里有两种不同的情况,所以我使用了两个scope变量,有竞价失败和竞价成功的情况. 同时我们使用timeout来计时,timeout是以ms作为单位的,当3000ms到了,模态框就会消失..
angular.module('partyBidApp') .controller('BidResultControl', function ($scope,$location,$routeParams, $timeout) {