File
Implements
layoutConfiguration
|
Type : any
|
|
Public
unsubscribe
|
Default value : new Subject<void>()
|
|
import { ResourceService, LayoutService } from '@sunbird/shared';
import { Component, OnInit } from '@angular/core';
import { GroupsService } from '../../services';
import { ActivatedRoute } from '@angular/router';
import { takeUntil } from 'rxjs/operators';
import { Subject } from 'rxjs';
@Component({
selector: 'app-back-button',
templateUrl: './back-button.component.html',
styleUrls: ['./back-button.component.scss']
})
export class BackButtonComponent implements OnInit {
layoutConfiguration: any;
public unsubscribe = new Subject<void>();
constructor(public resourceService: ResourceService,
private groupService: GroupsService, public layoutService: LayoutService, private activatedRoute: ActivatedRoute) { }
goBack() {
this.groupService.addTelemetry({id: 'back-button'}, this.activatedRoute.snapshot, []);
this.groupService.goBack();
}
ngOnInit() {
this.layoutConfiguration = this.layoutService.initlayoutConfig();
this.layoutService.switchableLayout().
pipe(takeUntil(this.unsubscribe)).subscribe(layoutConfig => {
if (layoutConfig != null) {
this.layoutConfiguration = layoutConfig.layout;
}
});
}
}
<button type="button" (click)="goBack()" [ngClass]="layoutConfiguration ? 'sb-btn-primary sb-btn-round' : 'sb-btn-link sb-btn-link-primary sb-left-icon-btn px-0'" class="sb-btn sb-btn-normal" tabindex="0" attr.aria-label="{{resourceService?.frmelmnts?.btn?.back}}"><i
class="icon-svg icon-svg--xxs icon-back"><svg class="icon icon-svg--primary">
<use xlink:href="assets/images/sprite.svg#arrow-long-left"></use>
</svg></i>
<span class="mx-8">{{resourceService?.frmelmnts?.btn?.back}}</span>
</button>
Legend
Html element with directive