import { Component, OnInit } from '@angular/core'; import { BsModalRef } from 'ngx-bootstrap'; import { KeywordsService } from '../../../services/keywords.service'; @Component({ selector: 'search-keywords', templateUrl: './search-keywords.component.html', styleUrls: ['./search-keywords.component.css'] }) export class SearchKeywordsComponent implements OnInit { search_keywords: any; keywords: any = []; constructor( public bsModalRef: BsModalRef, public keywordsService: KeywordsService ){ this.keywordsService.getAllKeywords().subscribe(keywords =>{ this.search_keywords = keywords['data'] as any[]; if(this.search_keywords && this.search_keywords.length > 0){ for(let i = 0; i < this.search_keywords.length ; i++) { this.keywords.push(this.search_keywords[i].keyword); } this.search_keywords = []; for(let i = 0; i < this.keywords.length ; i = i + 5) { this.search_keywords.push(this.keywords.slice(i, i + 5)) } for(let j = 0; j < this.search_keywords.length; j++){ this.search_keywords[j] = this.search_keywords[j].join(', '); } } }); } ngOnInit(): void { } }