### File

`src/app/shared/services/admin.service.ts`

### Index

###### Methods
deleteWord getWord postWord putWord

### Constructor

`constructor(http: HttpClient)`
Defined in src/app/shared/services/admin.service.ts:10
Parameters :
Name | Type | Optional | Description
http | `HttpClient` |  |

### Methods

deleteWord
`deleteWord(word: string)`
Defined in src/app/shared/services/admin.service.ts:49
Parameters :
Name | Type | Optional | Description
word | `string` |  |
Returns : `Observable<>`

getWord
`getWord(word: string)`
Defined in src/app/shared/services/admin.service.ts:17
Parameters :
Name | Type | Optional | Description
word | `string` |  |
Returns : `Observable<>`

postWord
`postWord(inputValue: string, inputCategory: string)`
Defined in src/app/shared/services/admin.service.ts:23
Parameters :
Name | Type | Optional | Description
inputValue | `string` |  |
inputCategory | `string` |  |
Returns : `any`

putWord
`putWord(inputValue: string, inputCategory: string, inputId: number)`
Defined in src/app/shared/services/admin.service.ts:36
Parameters :
Name | Type | Optional | Description
inputValue | `string` |  |
inputCategory | `string` |  |
inputId | `number` |  |
Returns : `any`

    import { Injectable, Inject, Input } from '@angular/core';
    import { Http, Response, Headers } from '@angular/http';
    import { Observable } from 'rxjs/Observable';
    import { HttpClient, HttpErrorResponse } from '@angular/common/http';
    import { IWord } from '../interface'
    import 'rxjs/add/operator/do';

    @Injectable()
    export class AdminService {

      constructor(private http: HttpClient) {
      }

      // To get word ID, Value and Category
      getWord(word: string): Observable<IWord> {
        return this.http.get<IWord>(`/api/admin/words/${word}`)
          .do((res => console.log(res)));
      }

      // To add new word to data base
      postWord(inputValue: string, inputCategory: string) {
        return this.http.post(`/api/admin/words`,
          (
            {
              'category': inputCategory,
              'value': inputValue
            }
          ))
          .do((res => console.log(res)));
      }

      // To Edit an existing word in data base
      putWord(inputValue: string, inputCategory: string, inputId: number) {
        return this.http.post(`/api/admin/words`,
          (
            {
              'category': inputCategory,
              'value': inputValue,
              'id': inputId
            }
          ))
          .do((res => console.log(res)));
      }

      // To Delete a word from database
      deleteWord(word: string): Observable<IWord> {
        return this.http.delete<IWord>(`/api/admin/words/${word}`)
          .do((res => console.log(res)));
      }

    }

# results matching ""

# No results matching ""