@@ -36,12 +36,11 @@ export class HasPermissionDirective {
|
|||||||
if (typeof permission !== 'string') {
|
if (typeof permission !== 'string') {
|
||||||
throw new Error('hasPermission value must be a string');
|
throw new Error('hasPermission value must be a string');
|
||||||
}
|
}
|
||||||
|
/** Clear the template beforehand to prevent overlap OnChanges. */
|
||||||
|
this.viewContainer.clear();
|
||||||
|
/** Shows Template if user has permission */
|
||||||
if (this.hasPermission(permission)) {
|
if (this.hasPermission(permission)) {
|
||||||
/** Shows Template */
|
|
||||||
this.viewContainer.createEmbeddedView(this.templateRef);
|
this.viewContainer.createEmbeddedView(this.templateRef);
|
||||||
} else {
|
|
||||||
/** Hides Template */
|
|
||||||
this.viewContainer.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user