initial import for Open Source 🎉
This commit is contained in:
parent
1898c361f3
commit
9c0dd3b722
2048 changed files with 218743 additions and 0 deletions
|
@ -0,0 +1,42 @@
|
|||
import { Directive, Inject, Input, AfterContentInit } from 'ng-metadata/core';
|
||||
|
||||
|
||||
/**
|
||||
* Structural directive that adds/removes its host element if the given list of feature flags are set.
|
||||
* Utilizes the existing AngularJS ngIf directive by applying its 'link' function to the host element's properties.
|
||||
*
|
||||
* Inspired by http://stackoverflow.com/a/29010910
|
||||
*/
|
||||
@Directive({
|
||||
selector: '[quayRequire]',
|
||||
legacy: {
|
||||
transclude: 'element',
|
||||
}
|
||||
})
|
||||
export class QuayRequireDirective implements AfterContentInit {
|
||||
|
||||
@Input('<quayRequire') public requiredFeatures: string[] = [];
|
||||
|
||||
private ngIfDirective: ng.IDirective;
|
||||
|
||||
constructor(@Inject('Features') private features: any,
|
||||
@Inject('$element') private $element: ng.IAugmentedJQuery,
|
||||
@Inject('$scope') private $scope: ng.IScope,
|
||||
@Inject('$transclude') private $transclude: ng.ITranscludeFunction,
|
||||
@Inject('ngIfDirective') ngIfDirective: ng.IDirective[]) {
|
||||
this.ngIfDirective = ngIfDirective[0];
|
||||
}
|
||||
|
||||
public ngAfterContentInit(): void {
|
||||
const attrs: {[name: string]: () => boolean} = {'ngIf': () => this.features.matchesFeatures(this.requiredFeatures)};
|
||||
|
||||
(<Function>this.ngIfDirective.link).apply(this.ngIfDirective,
|
||||
[
|
||||
this.$scope,
|
||||
this.$element,
|
||||
attrs,
|
||||
null,
|
||||
this.$transclude
|
||||
]);
|
||||
}
|
||||
}
|
Reference in a new issue