Add Angular UI Router definitions

- Move angular-ui definitions to its own folder
- Add self to readme
- Add some tests for angular-ui-router
This commit is contained in:
Michel Salib
2013-12-07 16:57:11 +01:00
parent a1bada0ac6
commit 3657670756
3 changed files with 141 additions and 0 deletions
+1
View File
@@ -30,6 +30,7 @@ List of Definitions
* [Add To Home Screen] (http://cubiq.org/add-to-home-screen) (by [James Wilkins] (http://www.codeplex.com/site/users/view/jamesnw))
* [AmCharts](http://www.amcharts.com/) (by [Covobonomo](https://github.com/covobonomo/))
* [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes))
* [AngularUI](http://angular-ui.github.io/) (by [Michel Salib](https://github.com/michelsalib))
* [AppFramework](http://app-framework-software.intel.com/) (by [Kyo Ago](https://github.com/kyo-ago))
* [Arbiter](http://arbiterjs.com/) (by [Arash Shakery](https://github.com/arash16))
* [async](https://github.com/caolan/async) (by [Boris Yankov](https://github.com/borisyankov))
+57
View File
@@ -0,0 +1,57 @@
/// <reference path="angular-ui-router.d.ts" />
var myApp = angular.module('testModule');
myApp.config((
$stateProvider: ng.ui.IStateProvider,
$urlRouterProvider: ng.ui.IUrlRouterProvider) => {
//
// For any unmatched url, redirect to /state1
$urlRouterProvider.otherwise("/state1");
//
// Now set up the states
$stateProvider
.state('state1', {
url: "/state1",
templateUrl: "partials/state1.html"
})
.state('state1.list', {
url: "/list",
templateUrl: "partials/state1.list.html",
controller: function($scope) {
$scope.items = ["A", "List", "Of", "Items"];
}
})
.state('state2', {
url: "/state2",
templateUrl: "partials/state2.html"
})
.state('state2.list', {
url: "/list",
templateUrl: "partials/state2.list.html",
controller: function($scope) {
$scope.things = ["A", "Set", "Of", "Things"];
}
}).state('index', {
url: "",
views: {
"viewA": { template: "index.viewA" },
"viewB": { template: "index.viewB" }
}
})
.state('route1', {
url: "/route1",
views: {
"viewA": { template: "route1.viewA" },
"viewB": { template: "route1.viewB" }
}
})
.state('route2', {
url: "/route2",
views: {
"viewA": { template: "route2.viewA" },
"viewB": { template: "route2.viewB" }
}
});
});
+83
View File
@@ -0,0 +1,83 @@
// Type definitions for Angular JS 1.1.5+ (ui.router module)
// Project: https://github.com/angular-ui/ui-router
// Definitions by: Michel Salib <michelsalib@hotmail.com>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../angularjs/angular.d.ts" />
declare module ng.ui {
interface IState {
template?: any;
templateUrl?: any;
templateProvider?: () => string;
controller?: any;
controllerProvider?: any;
resolve?: {};
url?: string;
params?: any[];
views?: {};
abstract?: boolean;
onEnter?: Function;
onExit?: Function;
data?: any;
}
interface IStateProvider extends IServiceProvider {
state(name:string, config:IState): IStateProvider;
decorator(name?: string, decorator?: (state: IState, parent: Function) => any): any;
}
interface IUrlMatcher {
concat(pattern: string): IUrlMatcher;
exec(path: string, searchParams: {}): {};
}
interface IUrlMatcherFactory {
compile(pattern: string): IUrlMatcher;
isMatcher(o: any): boolean;
parameters(): string[];
format(values: {}): string;
}
interface IUrlRouterProvider extends IServiceProvider {
when(whenPath: string, toPath: string): IUrlRouterProvider;
when(whenPath: RegExp, toPath: string): IUrlRouterProvider;
when(whenPath: IUrlMatcher, toPath: string): IUrlRouterProvider;
otherwise(path: string): IUrlRouterProvider;
otherwise(path: Function): IUrlRouterProvider;
rule(handler: Function): IUrlRouterProvider;
}
interface IStateOptions {
location?: any;
inherit?: boolean;
relative?: IState;
notify?: boolean;
}
interface IHrefOptions {
lossy?: boolean;
inherit?: boolean;
relative?: IState;
absolute?: boolean;
}
interface IStateService {
go(to: string, params?: {}, options?: IStateOptions): void;
transitionTo(state: string, params?: {}, updateLocation?: boolean): void;
transitionTo(state: string, params?: {}, options?: IStateOptions): void;
includes(state: string, params?: {}): boolean;
is(state:string, params?: {}): boolean;
is(state: IState, params?: {}): boolean;
href(state: IState, params?: {}, options?: IHrefOptions): string;
href(state: string, params?: {}, options?: IHrefOptions): string;
get(state: string): IState;
get(): IState[];
current: IState;
}
interface IStateParamsService {
[key: string]: any;
}
}