How to toggle Angular material expansion panel programmatically

前端 未结 6 1232
半阙折子戏
半阙折子戏 2021-02-12 16:20

I just started working on an Angular 4 project with material design.

I am currently working with the expansion component, the API states that a disabled expansion pa

6条回答
  •  旧巷少年郎
    2021-02-12 17:14

    expanded is set to true to expand the expansion panel and set to false to close the expansion panel. In the following example, expansion panel is programetically opened and closed. Please refer this link

    TS file

    import {Component} from '@angular/core';
    
    /**
     * @title Expansion panel as accordion
     */
    @Component({
      selector: 'expansion-steps-example',
      templateUrl: 'expansion-steps-example.html',
      styleUrls: ['expansion-steps-example.css']
    })
    export class ExpansionStepsExample {
      step = 0;
    
      setStep(index: number) {
        this.step = index;
      }
    
      nextStep() {
        this.step++;
      }
    
      prevStep() {
        this.step--;
      }
    }
    

    HTML file

    
      
        
          
            Personal data
          
          
            Type your name and age
            account_circle
          
        
    
        
          
        
    
        
          
        
    
        
          
        
      
    
      
        
          
            Destination
          
          
            Type the country name
            map
          
        
    
        
          
        
    
        
          
          
        
      
    
      
        
          
            Day of the trip
          
          
            Inform the date you wish to travel
            date_range
          
        
    
        
          
        
        
    
        
          
          
        
      
    
    
    

提交回复
热议问题