予想通り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が
「無効」であるので、そのは、(これは私が何を考えている)のみ最初のスイッチ状態を実行するこれで私を助けてください。
ありがとうございました。
おかげだAngular2でAngularjs 1.xの構文のように
に見えますたくさん:)私はアンを見落としたdocのularバージョン – Roxy