2

Angular - Material lists their documentation, and part of that includes an api for each component, for example their <mat-select> component:

https://material.angular.io/components/select/api

What is the proper method to include these api items, as they are not to be found on their website and it is unclear on where each item should be applied.

Z. Bagley
  • 8,942
  • 1
  • 40
  • 52
Snorlax
  • 4,425
  • 8
  • 37
  • 68

1 Answers1

4

Handy tips for using Angular - Material API docs (I have no idea why they don't include this type of info somewhere easy to access):

@Input(...) means that it is an attribute attached to a DOM element e.g. <mat-select ariaLabel="Custom aria label">

@Output() are defined emitted events that can be access through a ViewChild and Observable.

The rest of the definitions are typically methods that can be accessed through a ViewChild.

note: To see how to access the material elements with ViewChild check out this SO answer: Angular 2 material mat-select programmatically open/close

Z. Bagley
  • 8,942
  • 1
  • 40
  • 52
  • Thank you, still having issues though. I'm trying to have the select be automatically open when the page loads, but it's still not working. https://stackblitz.com/edit/angular-sxan5y?file=app/select-overview-example.ts – Snorlax Apr 12 '18 at 23:24
  • @Snorlax You need to use the method: `open()` alongside the preferred method when interacting with DOM `AfterViewInit`. https://stackblitz.com/edit/angular-sxan5y-3tprrf?file=app/select-overview-example.ts – Z. Bagley Apr 12 '18 at 23:43
  • Out of curiosity, how would I use panelOpen: boolean correctly? – Snorlax Apr 13 '18 at 01:11
  • @Snorlax for that one it's a `get()` method. That means that it already has a value you can "get" from it to determine the current state. The `open()` is a set, which means it makes an action on the object. Correct use would be `if ( this.mySelect.panelOpen ) { console.log('the panel is open') } else { console.log('the panel is NOT open') }` (it may be `panelOpen()`, doing this by memory) – Z. Bagley Apr 13 '18 at 02:46