码迷,mamicode.com
首页 > 其他好文 > 详细

angular 选中切换面板

时间:2017-08-16 11:39:23      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:ack   bsp   const   back   代码   cli   angular   fms   message   

此方法采用的是没有路由的方式;

html5 代码:

<div [hidden]="flag">
    <li class="music-list-datails">热门</li>
    <li class="music-list-datails" *ngFor="let c of category" [class.selected]="c === selectedc" (click)="onSelect(c)">{{c.category_name}}</li>
</div>
 
<div *ngIf="selectedc">
    <li class=" swiper-slide music-list-datails " (click)="goback()">返回上一级</li>
    <li class="swiper-slide music-list-datails " *ngFor="let audio of selectedc ">{{audio.tag_name}}</li>
</div>
ts代码:

ts代码:

errorMessage: string;
category: Category[];
selectedc: Tag[];
flag;
constructor(private fmService: FMService, private location: Location) { }
 ngOnInit() {
  this.getCategoryList();
 }
getCategoryList() {
    this.fmService.getCategoryList().then(
      category => {
       this.category = category;
     },
     error => this.errorMessage = <any>error
   )
  }
 
  onSelect(c): void {
   this.fmService.getAudiobook(c.id).then(
     tag => {
        this.selectedc = tag;
        this.flag = true;
     },
      error => this.errorMessage = <any>error
    )
  }

 

 

angular 选中切换面板

标签:ack   bsp   const   back   代码   cli   angular   fms   message   

原文地址:http://www.cnblogs.com/sulishibaobei/p/7371719.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!