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

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
9
  type = 'form';
范雪寒's avatar
范雪寒 committed
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

  constructor() {
    const tp = this.getQueryString('type');
    if (tp) {
      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;
  }
}