old-moya.component.ts 1.16 KB
import { Component, OnInit,  ViewChild, ElementRef } from '@angular/core';
import {Location, LocationStrategy, HashLocationStrategy, PathLocationStrategy} from "@angular/common";
import {NavigationExtras, ActivatedRoute} from "@angular/router";
import {Observable} from "rxjs";

@Component({
  selector: 'app-old-moya',
  providers: [Location, {provide: LocationStrategy, useClass: PathLocationStrategy}],
  templateUrl: './old-moya.component.html',
  styleUrls: ['./old-moya.component.css']
})
export class OldMoyaComponent implements OnInit {


  frameUrl: String = "/MoyaWeb/";



  @ViewChild('iframe') iframe: any;
  height: string = "1000px";



  constructor(private location: Location, private route: ActivatedRoute) {

    route.queryParamMap.map(a => a.get("p")).subscribe(x => {
      if(x) {
        this.frameUrl = "/MoyaWeb/" + x;
      }
    });
  }


  ngOnInit() { }

  changeUrl() {
    let tmpUrl = this.iframe.nativeElement.contentWindow.location.href.split("/MoyaWeb/",2);

    if(tmpUrl.length > 1) {
      this.location.replaceState("/old?p=" + tmpUrl[1]);
    }



    this.height = this.iframe.nativeElement.contentWindow.document.body.scrollHeight + "px";

  }

}