Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import { Directive, OnInit, HostBinding, Input } from '@angular/core';
  2.  
  3. @Directive({
  4. selector: '[appServerSuccess]'
  5. })
  6.  
  7. export class ServerSuccessDirective implements OnInit {
  8. @Input() appServerSuccess: string;
  9. @HostBinding()
  10. get innerText() {
  11. return this.appServerSuccess;
  12. }
  13. @HostBinding('class.success')
  14. get success () {
  15. return this.appServerSuccess.toLocaleLowerCase().includes('success');
  16. }
  17.  
  18. constructor() {}
  19. ngOnInit() {}
  20. }
  21.  
  22. import { NgModule } from "@angular/core";
  23. import { ServerSuccessDirective } from './directives/server-success.directive';
  24.  
  25.  
  26. @NgModule({
  27. imports: [ ],
  28. declarations: [ ServerSuccessDirective ],
  29. exports: [ ServerSuccessDirective ]
  30. })
  31.  
  32. export class SharedModule {}
  33.  
  34. <div [appServerSuccess]="msg"></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement