Commit 73358670 authored by wudizhanche1000's avatar wudizhanche1000

修正在Service上使用OnInit的错误

parent bac2a8c3
import {Injectable, OnInit} from "@angular/core"; import {Injectable} from "@angular/core";
import {Http} from "@angular/http"; import {Http} from "@angular/http";
import "rxjs/Rx"; import "rxjs/Rx";
import {App} from "./app"; import {App} from "./app";
...@@ -16,7 +16,7 @@ const Aria2 = window['System']._nodeRequire('aria2'); ...@@ -16,7 +16,7 @@ const Aria2 = window['System']._nodeRequire('aria2');
const execFile = window['System']._nodeRequire('child_process').execFile; const execFile = window['System']._nodeRequire('child_process').execFile;
@Injectable() @Injectable()
export class AppsService implements OnInit { export class AppsService {
currentApp: App; currentApp: App;
...@@ -36,10 +36,6 @@ export class AppsService implements OnInit { ...@@ -36,10 +36,6 @@ export class AppsService implements OnInit {
}) })
}, 1000); }, 1000);
}
ngOnInit() {
this.getApps(()=> { this.getApps(()=> {
//console.log(appsService.data) //console.log(appsService.data)
if (this.data.size > 0) { if (this.data.size > 0) {
...@@ -48,9 +44,6 @@ export class AppsService implements OnInit { ...@@ -48,9 +44,6 @@ export class AppsService implements OnInit {
}); });
} }
//localStorage = window['localStorage'];
private data: Map<string,App>; private data: Map<string,App>;
get allApps(): Map<string,App> { get allApps(): Map<string,App> {
...@@ -202,6 +195,7 @@ export class AppsService implements OnInit { ...@@ -202,6 +195,7 @@ export class AppsService implements OnInit {
return apps; return apps;
}).map(this.loadApps) }).map(this.loadApps)
.subscribe((apps) => { .subscribe((apps) => {
console.log(apps);
this.data = apps; this.data = apps;
// for (let app of data) { // for (let app of data) {
// } // }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment