文檔首頁>>telerik中文文檔>>可切換Button
可切換Button
您能夠通過按鈕指示它是激活的還是未激活的。若要使Button可切換,請更新toggleable屬性的默認(rèn)false配置并將其設(shè)置為true。
查看源代碼:
app.component.ts:
import { Component } from '@angular/core'; @Component({ selector: 'my-app', template: ` <div class="row"> <div class="col-xs-12 col-sm-6 example-col"> <p>Default Toggleable Button</p> <p class="k-block"> <button kendoButton (selectedChange)="onSelectedChange($event)" themeColor="primary" [toggleable]="true">Petrol</button> <button kendoButton (selectedChange)="onSelectedChange($event)" [toggleable]="true">Diesel</button> </p> </div> <div class="col-xs-12 col-sm-6 example-col"> <p>Flat Toggleable Button</p> <p class="k-block"> <button kendoButton fillMode="flat" themeColor="primary" [toggleable]="true">Petrol</button> <button kendoButton fillMode="flat" [toggleable]="true">Diesel</button> </p> </div> <div class="col-xs-12 col-sm-6 example-col"> <p>Outline Toggleable Button</p> <p class="k-block"> <button kendoButton fillMode="outline" themeColor="primary" [toggleable]="true">Petrol</button> <button kendoButton fillMode="outline" [toggleable]="true">Diesel</button> </p> </div> </div> ` }) export class AppComponent { public onSelectedChange(e: boolean): void { console.log(e); } }
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'; @NgModule({ bootstrap: [AppComponent], declarations: [AppComponent], imports: [BrowserModule, BrowserAnimationsModule, ButtonsModule], }) export class AppModule {}
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 });