From GandalfLife, 7 Months ago, written in JavaScript.
Embed
  1. import { Component, OnInit } from '@angular/core';
  2. import { UserService } from '../../shared/user.service';
  3. @Component({
  4.   selector: 'app-userinv',
  5.   templateUrl: './userinv.component.html',
  6.   styleUrls: ['./userinv.component.css']
  7. })
  8. export class UserinvComponent implements OnInit {
  9.  
  10.   constructor(private userService: UserService) { }
  11.  
  12.   ngOnInit() {
  13.   }
  14.   get User(){
  15.         return this.userService;
  16.   }
  17.  
  18.   addItem(item){
  19.         //Check if item is already in, else add it
  20.         if(!this.userService.checkItemArrUser(item)){
  21.                 this.userService.addItemArrUser(item)
  22.         }
  23.   }
  24.  
  25.   removeItem(item){
  26.         if(this.userService.checkItemArrUser(item)){
  27.                 this.userService.removeItemArrUser(item)
  28.         }
  29.   }
  30. }