123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- app.controller('AppCtrl', [ '$rootScope', '$scope', '$http', '$location', '$q', '$timeout', '$sce', function($rootScope, $scope, $http, $location, $q, $timeout, $sce) {
- $rootScope.showHtml = function(html) {
- var value = html.replace(/ /g, ' ').replace(/\n/g, '<br />');
- return $sce.trustAsHtml(value);
- }
- // Ajax统一请求函数
- $rootScope.ajaxRequest = function(params, fn) {
- if (params == undefined)
- params = {};
- if (params.data == undefined)
- params.data = {};
- var params = angular.extend({
- method : 'post'
- }, params);
-
- //http://art.hmsoft.cn/cy/exam/judge/grade/info/loginname.htm
-
-
- $http(params).then(function onSuccess(response) {
- // $.hideLoading();
- if (response == undefined)
- console.log(params);
- if (fn != undefined)
- fn.call(undefined, response.data);
- });
- };
- // 将date转换成长时间串
- $rootScope.longDateString = function(date) {
- date = new Date();
- if (angular.isDate(date))
- return date.toJSON();
- return "";
- };
- // 将date转换成长时间串
- $rootScope.longMinuteString = function(date) {
- return $rootScope.longDateString(date).substr(0, 15);
- };
- // 将日期转换成短时间串
- $rootScope.shortDateString = function(date) {
- if (date == undefined)
- return "";
- if (angular.isDate(date))
- date = date.toJSON();
- if (date.length > 10)
- return date.substr(0, 10);
- return date;
- };
- // 获取日期的时间串
- $rootScope.shortTimeString = function(date) {
- if (date == undefined)
- return "";
- if (angular.isDate(date))
- date = date.toJSON();
- if (date.length > 10)
- return date.substr(11, 5);
- return date;
- }
- // 将短日期时间串转换成日期
- $rootScope.parseShortString = function(date) {
- if (date == undefined)
- date = new Date();
- var str = $rootScope.shortDateString(date);
- return new Date(Date.parse(str.replace(/-/g, "/")));
- }
- // 将长时间串转化成日期
- $rootScope.parseLongString = function(date) {
- if (angular.isDate(date))
- return date;
- if (date == undefined || date.length != 19)
- return undefined;
- return new Date(Date.parse(date.replace(/-/g, "/")));
- }
- } ]);
|