mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Added definitions for ng-command
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
/// <reference path="ng-command.d.ts" />
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
var app = angular.module('testModule', ['ng-command']);
|
||||
|
||||
class CommandTestController {
|
||||
|
||||
constructor($command: ngCommand.ICommandFactory, $scope: ng.IScope, $timeout: ng.ITimeoutService) {
|
||||
|
||||
var cmd = $command($scope, () => {
|
||||
return $timeout(() => {}, 0)
|
||||
})
|
||||
|
||||
var cmdWithCanExecute = $command($scope, () => {
|
||||
return $timeout(() => {}, 0)
|
||||
}, () => false);
|
||||
|
||||
cmd.isExecuting === false;
|
||||
cmd.canExecute === false;
|
||||
cmd.execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
app.controller('TestController', CommandTestController);
|
||||
Vendored
+49
@@ -0,0 +1,49 @@
|
||||
// Type definitions for ng-command 0.2.0
|
||||
// Project: https://github.com/stephenlautier/ng-command
|
||||
// Definitions by: Stephen Lautier <https://github.com/stephenlautier>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module ngCommand {
|
||||
|
||||
var ModuleName: string;
|
||||
|
||||
/**
|
||||
* Command proxy object.
|
||||
*/
|
||||
interface ICommand {
|
||||
/**
|
||||
* Determines whether the command is currently executing.
|
||||
*/
|
||||
isExecuting: boolean;
|
||||
/**
|
||||
* Determines whether the command can execute or not.
|
||||
*/
|
||||
canExecute: boolean;
|
||||
/**
|
||||
* Executes the command function.
|
||||
*/
|
||||
execute: () => angular.IPromise<any>;
|
||||
}
|
||||
|
||||
class Command implements ICommand {
|
||||
static id: string;
|
||||
|
||||
isExecuting: boolean;
|
||||
canExecute: boolean;
|
||||
constructor($scope: angular.IScope, execute: () => angular.IPromise<any>, canExecute?: () => boolean);
|
||||
execute(): angular.IPromise<any>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Command factory which creates instances of @see ICommand.
|
||||
*/
|
||||
interface ICommandFactory {
|
||||
/**
|
||||
* Factory instance creator method.
|
||||
* @param $scope Scope which will keep track of the command.
|
||||
* @param execute The execute function when the command is executed.
|
||||
* @param canExecute Additional function which determines whether the command can executes.
|
||||
*/
|
||||
($scope: angular.IScope, execute: () => angular.IPromise<any>, canExecute?: () => boolean): ICommand;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user