• <menu id="w2i4a"></menu>
  • logo telerik中文文檔

    ButtonGroup事件


    立即下載Kendo UI for Angular

    Kendo UI for Angular的ButtonGroup提供了一個(gè)導(dǎo)航事件,每次鍵盤(pán)導(dǎo)航發(fā)生時(shí)都會(huì)觸發(fā)該事件。

    下面的示例演示了實(shí)際的事件。

    app.component.ts

    import { Component } from '@angular/core';
    
    @Component({
    selector: 'my-app',
    template: `
    <p>
    <kendo-buttongroup (navigate)="onNavigate($event)">
    <button kendoButton (click)="onClick('bold')" [toggleable]="true">Bold</button>
    <button kendoButton (click)="onClick('italic')" [toggleable]="true">Italic</button>
    <button kendoButton (click)="onClick('underline')" [toggleable]="true">Underline</button>
    </kendo-buttongroup>
    </p>
    <event-log title="Event log" [events]="events"></event-log>
    `
    })
    export class AppComponent {
    public events: string[] = [];
    
    public onNavigate(e: {[key:string]: boolean}): void {
    this.log('navigate');
    console.log(e);
    }
    
    public onClick(button: string): void {
    this.log(`${button} button clicked`);
    }
    
    private log(event: string): void {
    this.events.unshift(`${event}`);
    }
    }

    app.module.ts

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
    
    import { ButtonsModule } from '@progress/kendo-angular-buttons';
    import { AppComponent } from './app.component';
    import { EventLogComponent } from './event-log.component';
    
    @NgModule({
    bootstrap: [AppComponent],
    declarations: [AppComponent, EventLogComponent],
    imports: [BrowserModule, BrowserAnimationsModule, ButtonsModule]
    })
    export class AppModule {}

    event-log.component.ts

    import { Component, Input } from '@angular/core';
    
    @Component({
    selector: 'event-log',
    template: `
    <div class="example-config">
    <h5>{{ title }}</h5>
    <ul class="event-log">
    <li *ngFor="let event of events; let i = index">{{ logEvents(event, i) }}</li>
    </ul>
    </div>
    `,
    styles: [
    `
    .event-log {
    max-height: 208px;
    }
    `
    ]
    })
    export class EventLogComponent {
    @Input() title: string;
    @Input() events: string[];
    
    public logEvents(event: string, i: number): string {
    return `${this.events.length - i}. ${event}`;
    }
    }

    main.ts

    import './polyfills';
    
    import { enableProdMode } from '@angular/core';
    import { AppModule } from './app.module';
    import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
    
    enableProdMode();
    const platform = platformBrowserDynamic();
    platform.bootstrapModule(AppModule, { preserveWhitespaces: true });
    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();