I study Angular2, Typescript and reactive programming. I wrote a simple Typescript application on NodeJs that controls the change directory (main OS and file system). In one file. here https://github.com/maroshi/nodejs-directory-monitor/blob/master/app.ts
Now I want to add an interactive GUI to it using Angular2. I want to integrate my catalog monitor as a service into an Angular2 application.
Questions.
- Is it architecturally safe / correct to allow an Angular2 application access to the file system and OS (assuming it is a fancy NodeJs server)?
- How to integrate NodeJs utility library
fsinto Angular2 application.
I am using the Angular2 quickstart template from https://github.com/angular/quickstart .
I changed app.component.ts
import * as FileSystem from 'fs';
import { Component, OnInit } from '@angular/core';`
@Component({
selector: 'my-app',
template: `
<h1>My First Angular 2 App</h1>
<p>Some FileSystem info: {{dirInfo}}</p>
`
})
export class AppComponent implements OnInit {
private proccesInfo: string;
ngOnInit(){
let tmpString: string[] = FileSystem.readdirSync('/home');
this.dirInfo = tmpString != null ? tmpString[0] : 'undefined';
}
}
This compiles well, but does not load with errors:
GET XHR http:
Error: patchProperty/desc.set/wrapFn@http:
Zone</ZoneDelegate</ZoneDelegate.prototype.invokeTask@http:
Zone</Zone</Zone.prototype.runTask@http:
ZoneTask/this.invoke@http:
Error loading http:
Please report this study.
Note that tsconfig.json is the default tsconfig.json from the link above. Compilation for NodeJs
"module": "commonjs",
Thank you Joy and happiness
Dudi
source
share