src/app/home-page/categories/categories.component.ts
Container for all available tool categories. Each Category is generated based on the available tools.
| selector | app-categories |
| styleUrls | categories.component.css |
| templateUrl | ./categories.component.html |
Properties |
|
Methods |
constructor(toolService: ToolService, courseService: CourseService)
|
||||||||||||
|
Constructor
Parameters :
|
| setSelectedCategory | ||||||||
setSelectedCategory(category: Category)
|
||||||||
|
This sets the selected Category on the Tool service.
Parameters :
Returns :
boolean
Returns false to prevent the entire page (just the router) from reloading |
| Public courseService |
courseService:
|
Type : CourseService
|
|
Verifies if course selection is open,
so styling can be applied. Used in
categories.component.html (i.e. DO NOT DELETE)
**********************************************************
|
| Public toolService |
toolService:
|
Type : ToolService
|
|
Used to generate each available category
|
import { Component } from '@angular/core';
import { ToolService } from '../../tool.service';
import { CourseService } from '../../course.service'; // Being used in categories.component.html (i.e. DO NOT DELETE)
import { Category } from '../../interfaces';
/** **********************************************************
* Container for all available tool categories. Each {@link Category} is generated
* based on the available tools.
************************************************************/
@Component({
selector: 'app-categories',
templateUrl: './categories.component.html',
styleUrls: ['./categories.component.css']
})
export class CategoriesComponent {
/** **********************************************************
* Constructor
* @param toolService Used to generate each available category
* @param courseService Verifies if course selection is open,
* so styling can be applied. Used in
* categories.component.html (i.e. DO NOT DELETE)
************************************************************/
constructor(public toolService: ToolService,
public courseService: CourseService) { }
/** **********************************************************
* This sets the selected {@link Category} on the Tool service.
* @param {object} category The category to be set as the selected category
* @returns {false} Returns false to prevent the entire page (just the router) from reloading
************************************************************/
setSelectedCategory(category: Category) {
this.toolService.selectedCategory = category;
return false;
}
}
<div class="categories" [class.frosted]="this.courseService.courseSelectionOpen">
<div *ngFor="let category of toolService.categories" (click)="setSelectedCategory(category)">
<h1 class="white-text">{{category.title}}</h1>
<div class="tools">
<div *ngFor="let tool of this.toolService.toolList">
<div (click)="this.toolService.selectedTool = tool" [routerLink]="['tools', tool.id, 'options']" class="toolIcon card" style="display: block"
[style.display]="tool.toolCategory === category.toolCategory ? 'block' : 'none'">
<i class="material-icons charcoal-text">{{tool.icon}}</i>
<p>{{tool.title}}</p>
</div>
</div>
</div>
</div>
</div>