All files / stories/NativeFrameworkRendering/angular-components with-value.component.ts

66.66% Statements 4/6
100% Branches 0/0
50% Functions 1/2
60% Lines 3/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                                                6x 10x 10x                          
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'
 
@Component({
  selector: 'app-with-value',
  standalone: true,
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <div>
      <vg-dropdown
        label="Country"
        placeholder="Select your country"
        helper-text="This affects your shipping options"
        [options]="countryOptions"
        [value]="value"
        (vg-change)="onChange($event)"
        required
        data-testid="country-dropdown"
      ></vg-dropdown>
      <p style="margin-top: 12px;">
        Selected: <strong>{{ value }}</strong>
      </p>
    </div>
  `,
})
export class WithValueComponent {
  public value = 'us'
  public countryOptions = [
    { label: 'United States', value: 'us', description: 'North America' },
    { label: 'United Kingdom', value: 'uk', description: 'Europe' },
    { label: 'Canada', value: 'ca', description: 'North America' },
    { label: 'Australia', value: 'au', description: 'Oceania' },
    { label: 'Germany', value: 'de', description: 'Europe' },
  ]
 
  onChange(event: Event) {
    const customEvent = event as CustomEvent
    this.value = customEvent.detail.value
  }
}