Skip to content

Commit d26e9ff

Browse files
committed
0 parents  commit d26e9ff

File tree

6 files changed

+1188
-0
lines changed

6 files changed

+1188
-0
lines changed

app.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/// <reference path="includes/ts/angular.d.ts"/>
2+
3+
var app = angular.module("myApp", []);
4+
5+
//Set up our site routes
6+
app.config(($routeProvider) => {
7+
$routeProvider
8+
.when('/page1', <ng.Route>{ templateUrl: 'pages/page1.html' })
9+
.when('/page2', <ng.Route>{ templateUrl: 'pages/page2.html' })
10+
.when('/404', <ng.Route>{ templateUrl: 'pages/404.html' })
11+
.otherwise( <ng.Route>{ redirectTo: '/404' });
12+
})

default.html

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html ng-app="myApp">
3+
<head>
4+
<title>Multi-page SPA - Typescript and Angular</title>
5+
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet">
6+
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js" type="text/javascript"></script>
7+
<script src="app.js" type="text/javascript"></script>
8+
</head>
9+
10+
<body>
11+
12+
<div>
13+
<div ng-view></div>
14+
</div>
15+
16+
</body>
17+
</html>

includes/ts/angular.d.ts

Lines changed: 342 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,342 @@
1+
/// <reference path="jquery.d.ts"/>
2+
3+
interface AngularVersion {
4+
full: string;
5+
major: number;
6+
minor: number;
7+
dot: number;
8+
codeName: string;
9+
}
10+
11+
interface AngularModule {
12+
requires: string[];
13+
name: string;
14+
provider(name: string, providerType: Function): AngularModule;
15+
factory(name: string, providerFunction: Function): AngularModule;
16+
service(name: string, constructor: Function): AngularModule;
17+
value(name: string, object: any): AngularModule;
18+
constant(name: string, object: any): AngularModule;
19+
filter(name: string, filterFactory: Function): AngularModule;
20+
controller(name: string, constructor: Function): AngularModule;
21+
directive(name: string, directiveFactory: Function): AngularModule;
22+
config(configFn: Function): AngularModule;
23+
run(initializationFn: Function): AngularModule;
24+
}
25+
26+
interface AngularInjector {
27+
get(name: string): any;
28+
invoke(fn: Function, self?: any, locals?: any): any;
29+
instantiate(constructor: any, locals?: Object): any;
30+
annotate(fn: Function): string[];
31+
annotate(fns: string[]): string[];
32+
annotate(fns: Function[]): string[];
33+
}
34+
35+
interface JQuery {
36+
controller(name: string): Object;
37+
injector(): AngularInjector;
38+
scope(): ng.Scope;
39+
inheritedData(key?: string): any;
40+
}
41+
42+
interface AngularStatic {
43+
bootstrap(element: Element, modules: string[]): any;
44+
bootstrap(element: Element, modules: Function[]): any;
45+
copy(source: any, destination: Object): Object;
46+
copy(source: any, destination: Array): Array;
47+
extend(dest: Object, ...src: any[]): Object;
48+
equals(o1: any, o2: any): bool;
49+
element(element: string): JQuery;
50+
element(element: Element): JQuery;
51+
forEach(obj: Array, iterator: (value: any, index?: number) => void, context?: any): Array;
52+
forEach(obj: Object, iterator: (value: any, key?: string) => void, context?: any): Object;
53+
injector(modules: string[]): AngularInjector;
54+
injector(modules: Function[]): AngularInjector;
55+
module(name: string, requesires?: string[], configFn?: Function): AngularModule;
56+
module(name: string, configFn: Function): AngularModule;
57+
noop(): void;
58+
bind(self: Object, fn: Function, ...args: any[]): Function;
59+
toJson(obj: any, pretty: bool): string;
60+
fromJson(json: string): any;
61+
identity(...$: any[]): any;
62+
isUndefined(value: any): bool;
63+
isDefined(value: any): bool;
64+
isObject(value: any): bool;
65+
isString(value: any): bool;
66+
isNumber(value: any): bool;
67+
isDate(value: any): bool;
68+
isArray(value: any): bool;
69+
isFunction(value: any): bool;
70+
isElement(value: any): bool;
71+
lowercase(string: string): string;
72+
uppercase(string: string): string;
73+
//callbacks
74+
version: AngularVersion;
75+
}
76+
77+
declare module ng {
78+
79+
export interface Deregistration {
80+
();
81+
}
82+
83+
export interface CacheInfo {
84+
id: string;
85+
size: number;
86+
}
87+
88+
export interface Cache {
89+
put(key: string, value: any);
90+
get(key: string): any;
91+
remove(key: string);
92+
removeALl();
93+
destroy();
94+
info(): CacheInfo;
95+
}
96+
97+
export interface Provider {
98+
register(name: string, constructor: Function);
99+
}
100+
101+
export interface HttpConfig {
102+
method: string;
103+
url: string;
104+
params: Object;
105+
data: any;
106+
headers: Object;
107+
transformRequest: (data: any, headersGetter: () => Object) => void;
108+
transformResponse: (data: any, headersGetter: () => Object) => void;
109+
cache: Cache;
110+
timeout: number;
111+
withCredentials: bool;
112+
responseType: string;
113+
}
114+
115+
export interface HttpResponse {
116+
data: any;
117+
status: number;
118+
headers: (name: string) => string;
119+
config: HttpConfig;
120+
}
121+
122+
export interface HttpPromise {
123+
then(success: (response: HttpResponse) => void, error?: (response: HttpResponse) => void);
124+
success(callback: (response: HttpResponse) => void);
125+
error(callback: (response: HttpResponse) => void);
126+
}
127+
128+
export interface Http {
129+
(config: HttpConfig) : HttpPromise;
130+
pendingRequests: HttpConfig[];
131+
get(url: string, config?: HttpConfig): HttpPromise;
132+
delete(url: string, config?: HttpConfig): HttpPromise;
133+
head(url: string, config?: HttpConfig): HttpPromise;
134+
jsonp(url: string, config?: HttpConfig): HttpPromise;
135+
post(url: string, data: any, config?: HttpConfig): HttpPromise;
136+
put(url: string, data: any, config?: HttpConfig): HttpPromise;
137+
defaults: HttpConfig;
138+
}
139+
140+
export interface InterpolateProvider {
141+
startSymbol(): string;
142+
startSymbol(value: string): InterpolateProvider;
143+
endSymbol(): string;
144+
endSymbol(value: string): InterpolateProvider;
145+
}
146+
147+
export interface Interpolate {
148+
(text: string, mustHaveExpression?: bool): (context: Object) => string;
149+
startSymbol(): string;
150+
endSymbol(): string;
151+
}
152+
153+
export interface Location {
154+
absUrl(): string;
155+
url(): string;
156+
url(url: string): Location;
157+
protocol(): string;
158+
host(): string;
159+
port(): number;
160+
path(): string;
161+
path(path: string): Location;
162+
search(): string;
163+
search(search: string): Location;
164+
search(search: string, paramValue: string): Location;
165+
search(search: Object): Location;
166+
hash(): string;
167+
hash(hash: string): Location;
168+
replace(): Location;
169+
}
170+
171+
export interface LocationProvider {
172+
hashPrefix(): string;
173+
hashPrefix(prefix: string): LocationProvider;
174+
html5Mode(): any;
175+
html5Mode(mode: string): LocationProvider;
176+
}
177+
178+
export interface Log {
179+
log(...args: any[]);
180+
warn(...args: any[]);
181+
info(...args: any[]);
182+
error(...args: any[]);
183+
}
184+
185+
export interface Promise {
186+
then(successCallback: (result: any) => any, errorCallback?: (reason: any) => any): Promise;
187+
}
188+
189+
export interface Deferred {
190+
resolve(value);
191+
reject(reason);
192+
promise: Promise;
193+
}
194+
195+
export interface DeferredFactory {
196+
defer(): Deferred;
197+
reject(reason: any): Promise;
198+
when(value: any, success?: (result: any) => any, error?: (reason: any) => any): Promise;
199+
all(promises: Promise[]): Promise;
200+
}
201+
202+
export interface ScopeProvider {
203+
digestTtl(limit: number);
204+
}
205+
206+
export interface Scope {
207+
$new(isolate: bool): Scope;
208+
$watch(watchExpression: string, listener?: string, objectEquality?: bool): Deregistration;
209+
$watch(watchExpression: string, listener?: (newValue?: any, oldValue?: any, scope?: Scope) => any, objectEquality?: bool): Deregistration;
210+
$watch(watchExpression: (scope: Scope) => any, listener?: string, objectEquality?: bool): Deregistration;
211+
$watch(watchExpression: (scope: Scope) => any, listener?: (newValue?: any, oldValue?: any, scope?: Scope) => any, objectEquality?: bool): Deregistration;
212+
$digest();
213+
$destroy();
214+
$eval(): any;
215+
$eval(expression: string): any;
216+
$eval(expression: (scope?: Scope) => any): any;
217+
$evalAsync();
218+
$evalAsync(expression: string);
219+
$evalAsync(expression: (scope?: Scope) => any);
220+
$apply(): any;
221+
$apply(expression: string): any;
222+
$apply(expression: (scope?: Scope) => any): any;
223+
$on(name: string, listener: (event: Event) => any): Deregistration;
224+
$emit(name: string, ...args: any[]): Event;
225+
$broadcast(name: string, ...args: any[]): Event;
226+
}
227+
228+
export interface RouteMap {
229+
[key: string]: Function;
230+
}
231+
232+
export interface Route {
233+
controller?: any;
234+
template?: string;
235+
templateUrl?: string;
236+
resolve?: RouteMap;
237+
key: string;
238+
factory: any;
239+
redirectTo?: any;
240+
}
241+
242+
export interface RouteProvider {
243+
when(path: string, route: Route) : RouteProvider;
244+
otherwise(route: Route): RouteProvider;
245+
}
246+
247+
export interface RouteStatic {
248+
current: Route;
249+
routes: Route[];
250+
reload();
251+
}
252+
253+
export interface Timeout {
254+
(fn: Function, delay?: number, invokeApply?: bool): Promise;
255+
cancel(promise?: Promise): bool;
256+
}
257+
}
258+
259+
declare module ngCookies {
260+
export interface Cookies {
261+
[name: string]: Object;
262+
}
263+
264+
export interface CookieStore {
265+
get(key: string): Object;
266+
put(key: string, value: Object);
267+
remove(key: string);
268+
}
269+
}
270+
271+
declare module ngResource {
272+
export interface Action {
273+
method?: string;
274+
params?: Object;
275+
isArray?: bool;
276+
headers?: Object;
277+
}
278+
279+
export interface ActionHash {
280+
[action: string]: Action;
281+
}
282+
283+
export interface Resource {
284+
get(parameters?: Object, success?: Function, error?: Function): ResourceItem;
285+
save(postData: Object, success?: Function, error?: Function);
286+
save(postData: Array, success?: Function, error?: Function);
287+
save(parameters: Object, postData: Object, success?: Function, error?: Function);
288+
save(parameters: Object, postData: Array, success?: Function, error?: Function);
289+
query(parameters?: Object, success?: Function, error?: Function): ResourceItem[];
290+
remove(postData: Object, success?: Function, error?: Function);
291+
remove(postData: Array, success?: Function, error?: Function);
292+
remove(parameters: Object, postData: Object, success?: Function, error?: Function);
293+
remove(parameters: Object, postData: Array, success?: Function, error?: Function);
294+
delete(postData: Object, success?: Function, error?: Function);
295+
delete(postData: Array, success?: Function, error?: Function);
296+
delete(parameters: Object, postData: Object, success?: Function, error?: Function);
297+
delete(parameters: Object, postData: Array, success?: Function, error?: Function);
298+
}
299+
300+
export interface ResourceItem {
301+
$save(parameters?: Object, success?: Function, error?: Function);
302+
$remove(parameters?: Object, success?: Function, error?: Function);
303+
$delete(parameters?: Object, success?: Function, error?: Function);
304+
}
305+
}
306+
307+
declare var angular: AngularStatic;
308+
declare function $anchorScroll();
309+
declare function $cacheFactory(cacheId: string, options?: Object): ng.Cache;
310+
declare var $templateCache: ng.Cache;
311+
// TODO: $compile
312+
declare var $controllerProvider: ng.Provider;
313+
declare function $controller(constructor: Function, locals: Object): Object;
314+
declare function $controller(constructor: string, locals: Object): Object;
315+
declare var $document: JQuery;
316+
declare function $exceptionHandler(exception: Error, cause?: string);
317+
declare var $filterProvider: ng.Provider;
318+
declare function $filter(name: string): Function;
319+
declare var $http: ng.Http;
320+
declare var $interpolateProvider: ng.InterpolateProvider;
321+
declare var $interpolate: ng.Interpolate;
322+
declare var $locale: string;
323+
declare var $location: ng.Location;
324+
declare var $locationProvider: ng.LocationProvider;
325+
declare var $log: ng.Log;
326+
declare function $parse(expression: string): (context: Object, locals: Object) => any;
327+
declare var $q: ng.DeferredFactory;
328+
declare var $rootElement: JQuery;
329+
declare var $rootScopeProvider: ng.ScopeProvider;
330+
declare var $rootScope: ng.Scope;
331+
declare var $routeProvider: ng.RouteProvider;
332+
declare var $route: ng.RouteStatic;
333+
declare var $routeParams: Object;
334+
declare var $timeout: ng.Timeout;
335+
declare var $window: Window;
336+
337+
declare var $cookies: ngCookies.Cookies;
338+
declare var $cookieStore: ngCookies.CookieStore;
339+
340+
declare function $resource(url: string, paramDefaults?: Object, actions?: ngResource.ActionHash): ngResource.Resource;
341+
342+
declare function $sanitize(html: string): string;

0 commit comments

Comments
 (0)