Project

General

Profile

1
import {Component, ElementRef, Input} from '@angular/core';
2
 import {SafeHtmlPipe} from '../utils/pipes/safeHTML.pipe';
3
//<altmetrics [id]="10.7717/peerj.1150" type="doi"></altmetrics>
4
@Component({
5
  selector: 'altmetrics',
6
  template: `
7
   <div [innerHTML]="altmetrics | safeHtml"></div>
8
  `
9
})
10
export class AltMetricsComponent {
11
  @Input() id ;
12
  @Input() type = 'doi'; // doi or arxiv
13

    
14
  // public doi="10.7717/peerj.1150";
15
  public altmetrics:string;
16

    
17
  constructor() {
18
    if (typeof document !== 'undefined') {
19
       let yourModule = require('../utils/altmetrics.js');
20
     }
21
  }
22
  ngOnInit() {
23
   if(this.type == "doi"){
24
     this.altmetrics='<div data-badge-popover="right" data-badge-type="donut" data-doi="'+this.id+'" class="altmetric-embed"> </div>';
25
   }else{
26
     this.altmetrics='<div data-badge-popover="right" data-badge-type="donut" data-arxiv-id="'+this.id+'" class="altmetric-embed"> </div>';
27
   }
28
  }
29
}
(1-1/14)