ng-messages2
Version:
Angular version of ng-message
84 lines • 3.74 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var portal_1 = require("./portal");
var ClPortalHostDirective = (function (_super) {
__extends(ClPortalHostDirective, _super);
function ClPortalHostDirective(_componentFactoryResolver, _viewContainerRef) {
var _this = _super.call(this) || this;
_this._componentFactoryResolver = _componentFactoryResolver;
_this._viewContainerRef = _viewContainerRef;
return _this;
}
Object.defineProperty(ClPortalHostDirective.prototype, "portal", {
get: function () {
return this._portal;
},
/** Portal associated with the Portal host. */
set: function (p) {
if (p) {
this._replaceAttachedPortal(p);
}
},
enumerable: true,
configurable: true
});
ClPortalHostDirective.prototype.ngOnDestroy = function () {
this.dispose();
};
/**
* Attach the given TemplatePortal to this PortlHost as an embedded View.
* @param portal Portal to be attached.
*/
ClPortalHostDirective.prototype.attachTemplatePortal = function (portal) {
var _this = this;
portal.setAttachedHost(this);
this._viewContainerRef.createEmbeddedView(portal.templateRef);
this.setDisposeFn(function () { return _this._viewContainerRef.clear(); });
return new Map();
};
/** Detaches the currently attached Portal (if there is one) and attaches the given Portal. */
ClPortalHostDirective.prototype._replaceAttachedPortal = function (p) {
if (this.hasAttached()) {
this.detach();
}
if (p) {
this.attach(p);
this._portal = p;
}
};
return ClPortalHostDirective;
}(portal_1.BasePortalHost));
__decorate([
core_1.Input('clPortalHost'),
__metadata("design:type", portal_1.Portal),
__metadata("design:paramtypes", [portal_1.Portal])
], ClPortalHostDirective.prototype, "portal", null);
ClPortalHostDirective = __decorate([
core_1.Directive({
selector: '[clPortalHost]'
}),
__metadata("design:paramtypes", [core_1.ComponentFactoryResolver,
core_1.ViewContainerRef])
], ClPortalHostDirective);
exports.ClPortalHostDirective = ClPortalHostDirective;
//# sourceMappingURL=portalHost.directive.js.map