app.component.ts 592 Bytes
Newer Older
1
import { Component , OnInit} from '@angular/core';
liujiangnan's avatar
liujiangnan committed
2 3 4 5 6 7

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
liujiaxin's avatar
liujiaxin committed
8
export class AppComponent implements OnInit {
9
  type = 'play';
liujiangnan's avatar
liujiangnan committed
10

11
  constructor() {
liujiaxin's avatar
liujiaxin committed
12 13
    const tp = this.getQueryString('type');
    if (tp) {
liujiangnan's avatar
liujiangnan committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
      this.type = tp;
    }
  }

  ngOnInit() {

  }
  getQueryString(name) {
    const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    const r = window.location.search.substr(1).match(reg);
    if (r != null) {
      return unescape(r[2]);
    }
    return null;
  }
}