fix: has-permission directive for OnChanges (#795)

Fixes: #794
This commit is contained in:
Karan Takalkar
2020-05-23 20:23:22 +05:30
committed by GitHub
parent ac66a04527
commit 5b3d0c46dd
@@ -36,12 +36,11 @@ export class HasPermissionDirective {
if (typeof permission !== '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)) {
/** Shows Template */
this.viewContainer.createEmbeddedView(this.templateRef);
} else {
/** Hides Template */
this.viewContainer.clear();
}
}