Skip to content

Instantly share code, notes, and snippets.

//---- controller.js ----
$scope.pageNum = null;
$scope.currentPage = 0;
$scope.pageSize = 10;
/* get previous page data */
$scope.getPrevPage = function() {
$scope.currentPage = $scope.currentPage - 1;
}
@callblueday
callblueday / angularjs select
Last active December 20, 2015 21:39
angularjs select.you might as well define the array in your controller
<div ng-app>
<h2>Todo</h2>
<div ng-controller="QuarterController">
<select name="quarter" ng-model="Quarter"
ng-options="obj.value as obj.text for obj in [
{'value': 1,'text' : 'Q1'},{'value':2,'text':'Q2'},{'value':3,'text':'Q3'},{'value':4,'text':'Q4'}]">
</select>
</div>
</div>
@callblueday
callblueday / document Scroll method
Last active December 20, 2015 19:18
网页滚动条滚动加载函数
function (){
var times = 0;
//滚动条到网页头部的 高度,兼容ie,ff,chrome
var top = document.documentElement.scrollTop + document.body.scrollTop;
//网页的高度
var textheight = document.body.offsetHeight;
// 网页高度-top-当前窗口高度
if (textheight - top - window.innerHeight <= 50) {
if (times >= 20) {
return; //控制最大只能加载20次
@callblueday
callblueday / js毫秒转成日期
Last active December 20, 2015 19:18
格式化日期,将毫秒转化成字符串的快捷函数
/**
* Format Date
* usage:
* date2str(new Date(seconds*1000),"MM-dd hh:mm");
*/
date2str = function(x,y) {
var z = {M:x.getMonth()+1,d:x.getDate(),h:x.getHours(),m:x.getMinutes(),s:x.getSeconds()};
y = y.replace(/(M+|d+|h+|m+|s+)/g,function(v) {
return ((v.length>1?"0":"")+eval('z.'+v.slice(-1))).slice(-2)
});
@callblueday
callblueday / google closure Key events
Last active December 20, 2015 17:59
getting the enter key to be handled on press in an input/textbox
goog.events.listen(element, goog.events.EventType.KEYPRESS, function(a) {
if(a.keycode === 13) {
doSomething();
}
});
@callblueday
callblueday / enterEvents
Last active December 20, 2015 17:49
表单回车事件防止重复提交
document.onkeydown=function() {//捕捉回车
if (event.keyCode==13) {
checkFormValidate();
return false;
}
}