File

src/app/components/dashboard/dashboard.component.ts

Description

Gestione della dashboard principale del sito

Implements

OnInit

Example

Metadata

selector app-dashboard
styleUrls dashboard.component.css
templateUrl ./dashboard.component.html

Index

Properties
Methods

Constructor

constructor(router: Router, apiService: ApiService)

Costruttore del metodo DashboardComponent.

Parameters :
Name Type Optional
router Router no
apiService ApiService no

Methods

Private loadMain
loadMain()

Creazione menu superiore

Returns : void
ngOnInit
ngOnInit()

Inizializza il componente caricando i dati

Returns : void

Properties

Public items
items: MenuItem[]
Type : MenuItem[]
Default value : []
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { ApiService } from '../../services/api.service';
import { MenuItem } from 'primeng/api';
/**
 *Gestione della dashboard principale del sito
 *
 * @export
 * @class DashboardComponent
 * @implements {OnInit}
 */
@Component({
  selector: 'app-dashboard',
  templateUrl: './dashboard.component.html',
  styleUrls: ['./dashboard.component.css']
})
export class DashboardComponent implements OnInit {
  /**
   * Costruttore del metodo DashboardComponent.
   * @param {HttpClient} httpClient
   * @param {Router} router
   * @param {ApiService} apiService
   * @memberof DashboardComponent
   */
  constructor(private router: Router, private apiService: ApiService) {}

  public items: MenuItem[] = [];

  /**
   *Inizializza il componente caricando i dati
   *
   * @memberof DashboardComponent
   */
  ngOnInit() {
    this.loadMain();
  }

  /**
   * Creazione menu superiore
   *
   * @private
   * @memberof DashboardComponent
   */
  private loadMain() {
    this.apiService.getUrl().then(data => {
      Object.keys(data).forEach(element => {
        console.log('ele:' + element);
        if (element) {
          this.items.push({
            label: element,
            routerLink: 'list/' + element
          });
        }
      });
    });
  }
}
<div class="ui-g ui-fluid">


  <div class="ui-g-11">
    <p-tabMenu [model]="items"></p-tabMenu>
  </div>

  <div class="ui-g-1">
    <a href="https://swapi.co" target="_new">
      <img src="/assets/swapi.png" alt="API from swapi.co" height="48">
    </a>
    <a target="_new" href="https://commons.wikimedia.org/wiki/File:Star_Wars_Logo_2.svg#/media/File:Star_Wars_Logo_2.svg">
      <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/6d/Star_Wars_Logo_2.svg/100px-Star_Wars_Logo_2.svg.png"
        alt="Star Wars Logo 2.svg" height="48">
    </a>

  </div>

</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""