2017-10-12 12 views
0

我面對關於材料設計的官方文件的一些問題, 他們說如何禁用<MD-擴大面板> maetrial2 angular2

擴展面板使用禁用的屬性被禁用。禁用的擴展面板不能由用戶切換,但仍可以使用編程方式進行操作。

<mat-expansion-panel [disabled]="isDisabled"> 
    <mat-expansion-panel-header> 
    This is the expansion title 
    </mat-expansion-panel-header> 
    <mat-panel-description> 
    This is a summary of the content 
    </mat-panel-description> 
</mat-expansion-panel> 

但是,當我想它拋出一些錯誤 -

Uncaught Error: Template parse errors: 
Can't bind to 'disabled' since it isn't a known property of 'md-expansion-panel'. 
1. If 'md-expansion-panel' is an Angular component and it has 'disabled' input, then verify that it is part of this module. 
2. If 'md-expansion-panel' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. 
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. (" 

      <md-expansion-panel 
      [ERROR ->][disabled]="true" 

       routerLink="/settings/tools" 
") 

任何幫助嗎?

+0

您是否可以更新您的問題以顯示Angular版本和Angular Material版本? – nicholaschris

回答

0

當我在看的墊子 - 膨脹 - 面板代碼(selector: 'mat-expansion-panel')我看到它確實已禁用作爲它的一個輸入(inputs: ['disabled', 'expanded']),但我沒有看到它被使用......

我可能會建議一種解決方法:在墊子展開面板上設置pointer-events: none

0
<mat-expansion-panel [disabled]="isDisabled"> 
    <mat-expansion-panel-header> 
    This is the expansion title 
    </mat-expansion-panel-header> 
    <mat-panel-description> 
    This is a summary of the content 
    </mat-panel-description> 
</mat-expansion-panel> 

component.ts

禁用設定值 - this.isDisabled = TRUE;

啓用設置值 - this.isDisabled = false;

相關問題