首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Kendo UI TabStrip无法选择默认选项卡

Kendo UI TabStrip无法选择默认选项卡
EN

Stack Overflow用户
提问于 2016-10-26 19:33:25
回答 1查看 1.1K关注 0票数 0

我正尝试在我的页面中动态添加Kendo-UI tabstrip

我可以添加它,但在此之后,我无法将其作为默认文件打开。

我使用的代码如下所示。

代码语言:javascript
复制
import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  template: `
     <kendo-tabstrip [ngStyle]="{'width': '400px'}">
        <kendo-tabstrip-tab
          *ngFor="let item of items let i=index"
          [title]="item.city"
          [height]="height"
          [selected]="i == selected"
          [disabled]="item.disabled"
        >
            <span class="rainy">&nbsp;</span>
            <div class="weather">
                  <h2>{{item.temp}}<span>&ordm;C</span></h2>
                  <p>Rainy weather in {{item.city}}.</p>
            </div>
        </kendo-tabstrip-tab>
      </kendo-tabstrip>
    `
})

export class AppComponent {
  public selected: number = 0;
  public height: string = "300px";
  public items: any = [{
            disabled: false,
            city: "Paris",
            temp: 17
      }, {
            disabled: false,
            city: "New York",
            temp: 29
      }, {
            disabled: false,
            city: "Sofia",
            temp: 23
      }]

  constructor(){

    let a={
            city: "New Paris",
            temp: 20
      };

     setTimeout(() => {
      this.items.splice(0, 0, a);
      console.log(this.items);

      }, 100);

  }

}
EN

回答 1

Stack Overflow用户

发布于 2016-10-27 00:09:31

您可以加载动态标签并选择默认标签,如下所示-

代码语言:javascript
复制
import { Component } from '@angular/core';

@Component({
  selector: 'my-app',
  template: `
     <kendo-tabstrip [ngStyle]="{'width': '400px'}">
        <kendo-tabstrip-tab
          *ngFor="let item of items let i=index"
          [title]="item.city"
          [height]="height"
          [selected]="i == selected"
          [disabled]="item.disabled"
        >
            <span class="rainy">&nbsp;</span>
            <div class="weather">
                  <h2>{{item.temp}}<span>&ordm;C</span></h2>
                  <p>Rainy weather in {{item.city}}.</p>
            </div>
        </kendo-tabstrip-tab>
      </kendo-tabstrip>
    `
})

export class AppComponent {
  public selected: number = 1;
  public height: string = "300px";
  public items: any = [{
            disabled: true,
            city: "Paris",
            temp: 17
      }, {
            disabled: false,
            city: "New York",
            temp: 29
      }, {
            disabled: false,
            city: "Sofia",
            temp: 23
      }]
}

请参阅示例Plunker

看看这是否有帮助。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40261204

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档