Fixed sample HTTP REST call to dhis api (pair programming)
authorErik Haider Forsén <erikhf@ifi.uio.no>
Thu, 12 Nov 2015 12:01:58 +0000 (13:01 +0100)
committerErik Haider Forsén <erikhf@ifi.uio.no>
Thu, 12 Nov 2015 12:01:58 +0000 (13:01 +0100)
src/components/app.ts
src/components/filter/filter.html
src/components/filter/filter.ts

index 06aeb64..cb9479e 100644 (file)
@@ -18,4 +18,4 @@ class App {
 
 }
 
-bootstrap(App);
\ No newline at end of file
+bootstrap(App,[HTTP_PROVIDERS]);
\ No newline at end of file
index e3b16cd..2543c73 100644 (file)
@@ -1 +1,9 @@
-<div style="width: 500px; height:50px; background: cadetblue; ">Filter</div>
\ No newline at end of file
+<div style="width: 500px; height:50px; background: cadetblue; ">
+FILTER!!
+<!--
+    <div *ng-for="#orgUnit of result.organisationUnits">
+        {{orgUnit.name}}
+    </div>
+-->
+
+</div>
\ No newline at end of file
index b554b3c..a3a63b7 100644 (file)
@@ -1,4 +1,5 @@
-import {Component, CORE_DIRECTIVES} from 'angular2/angular2';
+import {Component, View, CORE_DIRECTIVES} from 'angular2/angular2';
+import {Headers, Http} from 'angular2/http';
 
 @Component({
     selector: 'mou-filter',
@@ -7,11 +8,27 @@ import {Component, CORE_DIRECTIVES} from 'angular2/angular2';
 })
 
 export class Filter {
-    writeYolo() {
-        console.log("yol");
-    }
+    result: Object;
 
-}
+    // Example HTTP request
+
+    /*
+    constructor(http: Http) {
+        var authHeader = new Headers();
+        authHeader.append('Authorization', 'Basic YWRtaW46ZGlzdHJpY3Q=');
+        this.result = {organisationUnits:[]};
+        http.get(dhisAPI+'/api/organisationUnits?paging=false', {headers: authHeader})
+        //http.get('orgunit.json')
+            .map(res => res.json()).subscribe(
+            res => this.result = res,
+            error => this.logError(error)
+        );
+    }
 
 
+    logError(error){
+        console.error(error);
+    }
 
+    */
+}