Reputation: 2480
i followed the syntax for ng-switch from official site:
https://angular.io/docs/ts/latest/api/common/index/NgSwitch-directive.html
and this is how i am using ng-switch :
<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 is "DISABLED" but still i am getting "This is customer data".
i print out the accessLevel just to verify and its "DIABLED"
here is my component:
@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);
}
I have also tried
ng-switch-when="accessLevel==ENABLED" and ng-switch-when="accessLevel===ENABLED"
but still its executing only the first switch condition(this is what i think), since accessLevel is "Disabled"
Please help me with this.
Thanks.
Upvotes: 0
Views: 533
Reputation: 657338
Your code looks like Angularjs 1.x syntax
In Angular2 it's *ngSwitchCase
, *ngSwitchDefault
, ...
See also
Upvotes: 2