Permalink
Browse files

Added HTTP types

  • Loading branch information...
1 parent 75e0f96 commit 15a5d49d8b22d321465b56dfc2d7bea684331df3 @markrendle committed Oct 9, 2012
@@ -78,6 +78,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
+ <Content Include="data\people.js" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
@@ -110,9 +111,9 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
- <ItemGroup>
+ <!--<ItemGroup>
<TypeScriptCompile Include="$(ProjectDir)\**\*.ts" />
- </ItemGroup>
+ </ItemGroup>-->
<Target Name="BeforeBuild">
<Exec Command="&quot;$(PROGRAMFILES)\Microsoft SDKs\TypeScript\0.8.0.0\tsc&quot; -target ES5 @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" />
</Target>

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -4,8 +4,11 @@
<title>AngularTS</title>
</head>
<body>
- <div ng-controller="MainController">
+ <div ng-controller="HomeController">
<h1>{{title}}</h1>
+ <ul>
+ <li ng-repeat="person in people">{{person.name}}</li>
+ </ul>
</div>
<script src="lib/angular/angular.js"></script>
<script src="js/app.js"></script>
@@ -1,9 +1,13 @@
var HomeController = (function () {
- function HomeController($scope) {
- this.initScope($scope);
+ function HomeController($scope, $http) {
+ $scope.title = "AngularTS";
+ $http.get("data/people.js").success(function (data) {
+ $scope.people = data;
+ });
}
- HomeController.prototype.initScope = function (scope) {
- scope.title = "AngularTS";
- };
+ HomeController.$inject = [
+ "$scope",
+ "$http"
+ ];
return HomeController;
})();
@@ -1,7 +1,21 @@
/// <reference path="../../../../angular.d.ts" />
+interface Person {
+ name: string;
+ occupation: string;
+}
+interface HomeScope extends Scope {
+ title: string;
+ people: Person[];
+}
+
class HomeController {
- constructor ($scope: Scope) {
- (<any>$scope).title = "AngularTS";
+ static $inject = ["$scope", "$http"];
+ constructor ($scope: HomeScope, $http: HttpService) {
+ $scope.title = "AngularTS";
+ $http.get("data/people.js")
+ .success((data) => {
+ $scope.people = <Person[]>data;
+ });
}
-}
+}
View
@@ -20,4 +20,41 @@ interface Scope {
$eval(exp: string): any;
$evalAsync(exp: Function): any;
$evalAsync(exp: string): any;
+}
+
+interface HttpRequest {
+ method?: string;
+ url?: string;
+ params?: any;
+ data?: any;
+ headers?: Object;
+ transformRequest?: any;
+ transformResponse?: any;
+ cache?: any;
+ timeout?: number;
+ withCredentials?: bool;
+}
+
+interface HttpResponse { data: any; status: number; headers: Function; config: any; }
+
+interface Promise {
+ then(successCallback: (result) => any, errorCallback?: (reason) => any): Promise;
+}
+
+interface HttpPromise {
+ then(successCallback: (response: HttpResponse) => any, errorCallback?: (response: HttpResponse) => any): Promise;
+ success(fn: (data: any) => any): HttpPromise;
+ success(fn: (data: any, status: number) => any): HttpPromise;
+ success(fn: (data: any, status: number, headers: () => any, config?: any) => any): HttpPromise;
+ success(fn: (data: any, status: number, headers: (key: string) => string, config?: any) => any): HttpPromise;
+ error(fn: (data: any) => any): HttpPromise;
+ error(fn: (data: any, status: number) => any): HttpPromise;
+ error(fn: (data: any, status: number, headers: () => any, config?: any) => any): HttpPromise;
+ error(fn: (data: any, status: number, headers: (key: string) => string, config?: any) => any): HttpPromise;
+}
+
+interface HttpService {
+ (request: HttpRequest): HttpPromise;
+ get(url: string): HttpPromise;
+ get(url: string, config: HttpRequest): HttpPromise;
}

0 comments on commit 15a5d49

Please sign in to comment.