Project

General

Profile

1
import {Component, Input} from '@angular/core';
2
import {ActivatedRoute} from '@angular/router';
3

    
4
@Component({
5
    selector: 'showTitle',
6
    template: `
7
        <h2 *ngIf="title != undefined">
8
            <span   *ngIf="title['url'] != undefined && title['url'] != null && title['url'] != ''"
9
                    class="custom-external">
10

    
11
                <a *ngIf="title['name'] != undefined && title['name'] != ''"
12
                    href="{{title['url']}}" target="_blank"
13
                    [innerHTML]="title['name']">
14
                </a>
15
                <a *ngIf="title['name'] == undefined || title['name'] == ''"
16
                    href="{{title['url']}}" target="_blank">
17
                    [no title available]
18
                </a>
19
            </span>
20
            <span *ngIf="(title['name'] != undefined && title['name'] != '') &&
21
                    (title['url'] == undefined || title['url'] == null || title['url'] == '')"
22
                    [innerHTML]="title['name']">
23
            </span>
24
            <span *ngIf="(title['name'] == undefined || title['name'] == '') &&
25
                    (title['url'] == undefined || title['url'] == null || title['url'] == '')"
26
                     >
27
                [no title available]
28
            </span>
29
        </h2>
30
        <h2 *ngIf="titleName">
31
          <span [innerHTML]="titleName"></span>
32
        </h2>
33
        <h2 *ngIf="!titleName && !title">
34
          <span>[no title available]</span>
35
        </h2>
36
    `
37

    
38
    })
39

    
40
export class ShowTitleComponent {
41
  @Input() titleName: string;
42
  @Input() title: { [key: string]: string };
43
  @Input() iconClass:string;
44

    
45
  sub: any;
46

    
47
  constructor (private route: ActivatedRoute) {}
48

    
49
  ngOnInit() {
50
    this.sub = this.route.queryParams.subscribe(
51
      params => {
52
        console.info("onInit showTitle");
53
      }
54
    );
55
  }
56

    
57
  ngOnDestroy() {
58
    console.info("onDestroy showTitle");
59
    this.sub.unsubscribe();
60
  }
61
}
(15-15/17)