src/app/pages/dashboard/contacts/contacts.component.ts
selector | ngx-contacts |
styleUrls | contacts.component.scss |
templateUrl | ./contacts.component.html |
Properties |
Methods |
constructor(userService: UserService, themeService: NbThemeService, breakpointService: NbMediaBreakpointsService)
|
||||||||||||
Parameters :
|
ngOnDestroy |
ngOnDestroy()
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
breakpoint |
breakpoint:
|
Type : NbMediaBreakpoint
|
breakpoints |
breakpoints:
|
Type : any
|
contacts |
contacts:
|
Type : any[]
|
recent |
recent:
|
Type : any[]
|
themeSubscription |
themeSubscription:
|
Type : any
|
import { Component, OnDestroy, OnInit } from '@angular/core';
import { NbThemeService, NbMediaBreakpoint, NbMediaBreakpointsService } from '@nebular/theme';
import { UserService } from '../../../@core/data/users.service';
@Component({
selector: 'ngx-contacts',
styleUrls: ['./contacts.component.scss'],
templateUrl: './contacts.component.html',
})
export class ContactsComponent implements OnInit, OnDestroy {
contacts: any[];
recent: any[];
breakpoint: NbMediaBreakpoint;
breakpoints: any;
themeSubscription: any;
constructor(private userService: UserService,
private themeService: NbThemeService,
private breakpointService: NbMediaBreakpointsService) {
this.breakpoints = this.breakpointService.getBreakpointsMap();
this.themeSubscription = this.themeService.onMediaQueryChange()
.subscribe(([oldValue, newValue]) => {
this.breakpoint = newValue;
});
}
ngOnInit() {
this.userService.getUsers()
.subscribe((users: any) => {
this.contacts = [
{user: users.nick, type: 'mobile'},
{user: users.eva, type: 'home'},
{user: users.jack, type: 'mobile'},
{user: users.lee, type: 'mobile'},
{user: users.alan, type: 'home'},
{user: users.kate, type: 'work'},
];
this.recent = [
{user: users.alan, type: 'home', time: '9:12 pm'},
{user: users.eva, type: 'home', time: '7:45 pm'},
{user: users.nick, type: 'mobile', time: '5:29 pm'},
{user: users.lee, type: 'mobile', time: '11:24 am'},
{user: users.jack, type: 'mobile', time: '10:45 am'},
{user: users.kate, type: 'work', time: '9:42 am'},
{user: users.kate, type: 'work', time: '9:31 am'},
{user: users.jack, type: 'mobile', time: '8:01 am'},
];
});
}
ngOnDestroy() {
this.themeSubscription.unsubscribe();
}
}
<nb-card [size]="breakpoint.width >= breakpoints.xxxl || breakpoint.width < breakpoints.md ? 'large' : 'xlarge'">
<nb-tabset fullWidth>
<nb-tab tabTitle="Contacts">
<div class="contact" *ngFor="let c of contacts">
<nb-user [picture]="c.user.picture" [name]="c.user.name" [title]="c.type" size="large"></nb-user>
<i class="i-contact nb-phone"></i>
</div>
</nb-tab>
<nb-tab tabTitle="Recent">
<div class="contact" *ngFor="let c of recent">
<nb-user [picture]="c.user.picture" [name]="c.user.name" [title]="c.type" size="large"></nb-user>
<span class="time">{{ c.time }}</span>
</div>
</nb-tab>
</nb-tabset>
</nb-card>