2016-11-09 6 views
0

予想通りNG-スイッチ動作していない私は、公式サイトからNG-スイッチの構文に従っAngular2:</p> <p><a href="https://angular.io/docs/ts/latest/api/common/index/NgSwitch-directive.html" rel="nofollow noreferrer">https://angular.io/docs/ts/latest/api/common/index/NgSwitch-directive.html</a></p> <p>、これは私がNG-スイッチを使用しています方法です:

<div ng-switch="accessLevel"> 
<div class="customer" ng-switch-when="ENABLED">This is customer data</div> 
<div class="customer-blurr" ng-switch-when="DISABLED"> This is disabled Customer Data</div> 
<div class="customer-blurr" ng-switch-default> <demo-error [componentName]="componentname"></demo-error></div> 
</div> 

accessLevelは「DISABLED」ですが、引き続き「This is customer data」です。

@Component({ 
    selector: 'customer', 
    templateUrl: './customer.component.html', 
    styleUrls: ['./customer.component.css'] 
}) 
export class CustomerComponent extends SuperChildComponent{ 
    public allowed: boolean = false; 
    public accessLevel:AccessLevel =null; 
    public componentname:string; 

    constructor(private authenticationService : AuthorizationService) { 
    super(); 
    this.componentname=this.constructor.name; 
    this.accessLevel=this.authenticationService.isUserLoggedIn()?this.authenticationService.componentAccessLevel(this.constructor.name):null; 
    console.log(this.constructor.name +' has '+this.accessLevel); 
    } 

私は

NG-スイッチを試してみました:私はちょうど確認するためにACCESSLEVELをプリントアウトし、ここではその "DIABLED"

は私のコンポーネントである

-when = "accessLevel == ENABLED"と ng-switch-when = "accessLevel === ENABLED"

それでもACCESSLEVELが

「無効」であるので、そのは、(これは私が何を考えている)のみ最初のスイッチ状態を実行するこれで私を助けてください。

ありがとうございました。

答えて

関連する問題

 関連する問題