src/tiles/clickable-tile.component.ts
Build application's clickable tiles using this component. Get started with importing the module:
Example :import { TilesModule } from 'carbon-components-angular';
<cds-clickable-tile>
tile content
</cds-clickable-tile>
selector | cds-clickable-tile, ibm-clickable-tile |
template |
|
Methods |
Inputs |
Outputs |
constructor(router: Router)
|
||||||
Defined in src/tiles/clickable-tile.component.ts:84
|
||||||
Parameters :
|
disabled | |
Type : boolean
|
|
Default value : false
|
|
Defined in src/tiles/clickable-tile.component.ts:67
|
|
Set to |
href | |
Type : string
|
|
Default value : "#"
|
|
Defined in src/tiles/clickable-tile.component.ts:52
|
|
Sets the |
rel | |
Type : string
|
|
Defined in src/tiles/clickable-tile.component.ts:62
|
|
Sets the |
route | |
Type : any[]
|
|
Defined in src/tiles/clickable-tile.component.ts:73
|
|
Array of commands to send to the router when the link is activated See: https://angular.io/api/router/Router#navigate |
routeExtras | |
Type : any
|
|
Defined in src/tiles/clickable-tile.component.ts:79
|
|
Router options. Used in conjunction with |
target | |
Type : string
|
|
Defined in src/tiles/clickable-tile.component.ts:57
|
|
Sets the |
theme | |
Type : "light" | "dark"
|
|
Default value : "dark"
|
|
Defined in src/tiles/clickable-tile.component.ts:47
|
navigation | |
Type : EventEmitter
|
|
Defined in src/tiles/clickable-tile.component.ts:84
|
|
Emits the navigation status promise when the link is activated |
navigate | ||||
navigate(event)
|
||||
Defined in src/tiles/clickable-tile.component.ts:88
|
||||
Parameters :
Returns :
void
|
import {
Component,
Input,
Output,
EventEmitter,
Optional
} from "@angular/core";
import { Router } from "@angular/router";
/**
* Build application's clickable tiles using this component. Get started with importing the module:
*
* ```typescript
* import { TilesModule } from 'carbon-components-angular';
* ```
*
* ```html
* <cds-clickable-tile>
* tile content
* </cds-clickable-tile>
* ```
*/
@Component({
selector: "cds-clickable-tile, ibm-clickable-tile",
template: `
<a
cdsLink
class="cds--tile cds--tile--clickable"
[ngClass]="{
'cds--tile--light': theme === 'light',
'cds--tile--disabled cds--link--disabled' : disabled
}"
tabindex="0"
(click)="navigate($event)"
[attr.href]="disabled ? null : href"
[attr.target]="target"
[attr.rel]="rel ? rel : null"
[attr.aria-disabled]="disabled">
<ng-content></ng-content>
</a>`
})
export class ClickableTile {
/**
* @deprecated since v5 - Use `cdsLayer` directive instead
* Set to `"light"` to apply the light style
*/
@Input() theme: "light" | "dark" = "dark";
/**
* Sets the `href` attribute on the `cds-clickable-tile` element.
*/
@Input() href = "#";
/**
* Sets the `target` attribute on the `cds-clickable-tile` element.
*/
@Input() target: string;
/**
* Sets the `rel` attribute on the `cds-clickable-tile` element.
*/
@Input() rel: string;
/**
* Set to `true` to disable the clickable tile.
*/
@Input() disabled = false;
/**
* Array of commands to send to the router when the link is activated
* See: https://angular.io/api/router/Router#navigate
*/
@Input() route: any[];
/**
* Router options. Used in conjunction with `route`
* See: https://angular.io/api/router/Router#navigate
*/
@Input() routeExtras: any;
/**
* Emits the navigation status promise when the link is activated
*/
@Output() navigation = new EventEmitter<Promise<boolean>>();
constructor(@Optional() protected router: Router) {}
navigate(event) {
if (this.router && this.route && !this.disabled) {
event.preventDefault();
const status = this.router.navigate(this.route, this.routeExtras);
this.navigation.emit(status);
}
}
}