SHARE
TWEET

Untitled

a guest Sep 17th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import {Component, forwardRef, Input, OnInit} from '@angular/core';
  2. import {ViewerAccordionAbstract} from '../viewer-data/domains/viewer-accordion.abstract';
  3.  
  4. @Component({
  5.   selector: 'app-viewer-secret',
  6.   template: `
  7.     <div class="row">
  8.       <div class="col-12 ">
  9.         <div class="form-group">
  10.           <label for="exampleInputPassword1">Secret Word</label>
  11.           <input type="password" class="form-control" id="exampleInputPassword1" [(ngModel)]="secret">
  12.         </div>
  13.         <zt-viewer-accordion [data]="data"></zt-viewer-accordion>
  14.         <div class="alert alert-danger" role="alert" *ngIf="showError">
  15.           Your Secret Word '{{secret}}' is incorrect, try with <b>sample</b>
  16.         </div>
  17.       </div>
  18.     </div>
  19.   `,
  20.   styleUrls: ['./viewer-secret.component.scss'],
  21.   viewProviders: [
  22.     {
  23.       provide: ViewerAccordionAbstract,
  24.       useExisting: forwardRef(() => ViewerSecretComponent)
  25.     }
  26.   ]
  27. })
  28. export class ViewerSecretComponent extends ViewerAccordionAbstract implements OnInit {
  29.   @Input() data: any = {};
  30.   @Input() key: any = 'sample';
  31.   secret: string = '';
  32.   showError: boolean = false;
  33.   constructor() {
  34.     super();
  35.   }
  36.  
  37.   ngOnInit(): void {
  38.   }
  39.  
  40.   /**
  41.    *  Comparamos el valor proporcionado por el cliente con la clave del component
  42.    */
  43.  
  44.   validOpen() {
  45.     return this.secret == this.key;
  46.   }
  47.  
  48.   /**
  49.    * Si el valor no es igual a la clave del component, se ejecutará deferClick que mostrará un
  50.    * mensaje de error .
  51.    */
  52.  
  53.   deferClick() {
  54.     this.showError = true;
  55.     setTimeout(() => {
  56.       this.showError = false;
  57.     }, 2000);
  58.   }
  59.  
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top