Wire up a SegmentedBar

Nathan Walker shows us how to wire up a SegmentedBar.

  • <SegmentedBar items="{{items}}" selectedIndexChanged="{{selectSegment}}" />
    <Label text="{{selectedItem}}" />
    
          
  •         
    
    import {Observable} from 'data/observable';
    
    export class Snippet extends Observable {
      public selectedItem: string;
      public items: Array<any> = [
        { title: 'Strawberry' },
        { title: 'Blueberry' },
        { title: 'Raspberry' }
      ];
    
      constructor() {
        super();  
        this.selectedItem = `Selected: ${this.items[0].title}`; 
      }
    
      public selectSegment(e: any) {
        this.set('selectedItem', `Selected: ${this.items[e.newIndex].title}`);  
      }  
    }