Skip to content

Instantly share code, notes, and snippets.

@websiddu
Created July 1, 2016 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save websiddu/7ca8a1b1611c0d1b0c8c837570ae4cee to your computer and use it in GitHub Desktop.
Save websiddu/7ca8a1b1611c0d1b0c8c837570ae4cee to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import { ApiService } from '../shared/services/api/api.service';
import { DocframeComponent } from '../shared/docframe/docframe.component';
import {DomSanitizationService, SafeResourceUrl} from '@angular/platform-browser';
@Component({
moduleId: module.id,
selector: 'app-doc',
templateUrl: 'doc.component.html',
styleUrls: ['doc.component.css'],
providers: [ApiService],
directives: [DocframeComponent]
})
export class DocComponent implements OnInit {
public docUrl: any;
public files: any;
constructor(private sanitationService:DomSanitizationService, private api: ApiService) {
}
loadFiles() {
this.api.getDocsList().subscribe(this._updateFilesList.bind(this))
}
createDoc() {
this.api.createNewDoc().subscribe(
this._updateDocUrl.bind(this),
this._logError.bind(this)
)
}
_updateFilesList(files) {
this.files = files;
}
_updateDocUrl(docUrl) {
this.docUrl = this.sanitationService.bypassSecurityTrustResourceUrl(docUrl);
}
_logError() {
}
ngOnInit() {
this.api.getAuth().subscribe(()=> {
this.loadFiles();
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment