src/list/list.directive.ts
Applies either ordered or unordered styling to the list container it is applied to.
For ul
s it will apply unordered list styles, and for ol
s it will apply ordered list styles.
If a ul
or ol
is nested within a li
the directive will apply nested list styling.
Get started with importing the module:
Example :import { ListModule } from 'carbon-components-angular';
Selector | [cdsList], [ibmList] |
Inputs |
HostBindings |
Accessors |
constructor(elementRef: ElementRef)
|
||||||
Defined in src/list/list.directive.ts:44
|
||||||
Parameters :
|
isExpressive | |
Type : boolean
|
|
Default value : false
|
|
Defined in src/list/list.directive.ts:44
|
|
Set to |
class.cds--list--nested |
Type : boolean
|
Defined in src/list/list.directive.ts:37
|
class.cds--list--ordered |
Type : boolean
|
Defined in src/list/list.directive.ts:27
|
class.cds--list--unordered |
Type : boolean
|
Defined in src/list/list.directive.ts:32
|
ordered |
getordered()
|
Defined in src/list/list.directive.ts:27
|
unordered |
getunordered()
|
Defined in src/list/list.directive.ts:32
|
nested |
getnested()
|
Defined in src/list/list.directive.ts:37
|
import {
Directive,
ElementRef,
HostBinding,
Input
} from "@angular/core";
/**
* Applies either ordered or unordered styling to the list container it is applied to.
*
* For `ul`s it will apply unordered list styles, and for `ol`s it will apply ordered list styles.
*
* If a `ul` or `ol` is nested within a `li` the directive will apply nested list styling.
*
* Get started with importing the module:
*
* ```typescript
* import { ListModule } from 'carbon-components-angular';
* ```
*
* [See demo](../../?path=/story/components-list--basic)
*/
@Directive({
selector: "[cdsList], [ibmList]"
})
export class List {
@HostBinding("class.cds--list--ordered") get ordered() {
if (this.nested) { return false; }
return this.elementRef.nativeElement.tagName === "OL";
}
@HostBinding("class.cds--list--unordered") get unordered() {
if (this.nested) { return false; }
return this.elementRef.nativeElement.tagName === "UL";
}
@HostBinding("class.cds--list--nested") get nested() {
return !!(this.elementRef.nativeElement.parentElement && this.elementRef.nativeElement.parentElement.tagName === "LI");
}
/**
* Set to `true` to make list expressive
*/
@Input() @HostBinding("class.cds--list--expressive") isExpressive = false;
constructor(protected elementRef: ElementRef) {}
}