add sorting for gallery
This commit is contained in:
38
pdb-js/src/app/image-toggle/image-toggle.component.ts
Normal file
38
pdb-js/src/app/image-toggle/image-toggle.component.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'pdb-image-toggle',
|
||||
templateUrl: './image-toggle.component.html',
|
||||
styleUrls: ['./image-toggle.component.scss']
|
||||
})
|
||||
export class ImageToggleComponent implements OnInit {
|
||||
|
||||
@Input()
|
||||
images : string = "";
|
||||
|
||||
value: number = 0;
|
||||
|
||||
@Output()
|
||||
valueChanged : EventEmitter<number> = new EventEmitter<number>();
|
||||
|
||||
_states : Array<any>;
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
this._states = JSON.parse(this.images);
|
||||
}
|
||||
|
||||
imageUrl() : string {
|
||||
return this._states[this.value].imageUrl;
|
||||
}
|
||||
|
||||
title() : string {
|
||||
return this._states[this.value].title;
|
||||
}
|
||||
|
||||
toggle(event){
|
||||
this.value = (this.value+1) % this._states.length;
|
||||
this.valueChanged.emit(this.value);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user