@ -100,8 +100,9 @@ module Developer{
}
export class DataModelService {
public data = [ ] ;
public paramOptions = new OptionsParams ( ) ;
public data :Array < any > = [ ] ;
public paramOptions : OptionsParams = new OptionsParams ( ) ;
public transferTasks : Array < any > = [ ] ;
constructor ( ) {
this . updateModel ( ) ;
@ -148,15 +149,38 @@ module Developer{
//根据key获取用户选择参数
public getParamOption ( key :string ) {
return this . paramOptions [ key ] ;
}
public startIntervalTask ( $interval , $http ) {
var result ;
var timer = $interval ( ( ) = > {
$ . ajax ( {
async : false ,
type : "POST" ,
url : "/java/console/api/task/transfer/list" ,
success : function ( data ) {
if ( data ) {
result = data ;
}
}
} ) ;
this . transferTasks = result ;
} , 1500 ) ;
timer . then ( ( ) = > {
console . log ( "Done!" ) ;
} , ( ) = > {
console . log ( "error" ) ;
} , ( ) = > {
console . log ( "每次都更新" ) ;
} ) ;
}
}
//创建数据模型服务
_module . factory ( "DataModel" , [ '$rootScope' , '$http' , '$location' , '$resource' , ( $rootScope , $http , $location , $resource ) = > {
var $scope = new DataModelService ( ) ;
return $scope ;
_module . factory ( "DataModel" , [ '$rootScope' , '$http' , '$interval' , '$location' , '$resource' , ( $rootScope , $http , $interval , $location , $resource ) = > {
var $scope = new DataModelService ( ) ;
$scope . startIntervalTask ( $interval , $http ) ;
return $scope ;
} ] ) ;
}