UNPKG

ng-error-message

Version:

Displays error messages when a form control is invalid avoiding the long list of tags for each error

2 lines 2.03 kB
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("ng-error-message",["exports","@angular/core"],r):r(e["ng-error-message"]={},e.ng.core)}(this,function(e,r){"use strict";function t(){}var o=(n.prototype.getDictionary=function(){if(!/.json$/.test(this._dictURl))throw this._dictURl+" must be a json file";return this._http.get(this._dictURl)},n);function n(e,r){this._http=e,this._dictURl=r}var s=(Object.defineProperty(a.prototype,"errors",{get:function(){return this._errors},enumerable:!0,configurable:!0}),a.prototype.load=function(){var r=this;this._loader.getDictionary().subscribe(function(e){r._errors=e})},a.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],a.ctorParameters=function(){return[{type:t}]},a.ngInjectableDef=r.defineInjectable({factory:function(){return new a(r.inject(t))},token:a,providedIn:"root"}),a);function a(e){this._loader=e,this._errors={}}var i=(c.prototype.transform=function(e,r){if(void 0===r&&(r={}),!e||"object"!=typeof e||Array.isArray(e)||"object"!=typeof r||Array.isArray(r))return null;var t=Object.keys(e)[0],o=r[t],n=t!==undefined&&this._errorMessageSrv.errors[t]||null;if(this._cachedCleanMessage===n)return this._cachedTransformedMessage;if(this._cachedCleanMessage=n)for(var s in o)n=n.replace(new RegExp("{{\\s?"+s+"\\s?}}","g"),o[s]);return this._cachedTransformedMessage=n},c.decorators=[{type:r.Pipe,args:[{name:"errorMessage",pure:!1}]}],c.ctorParameters=function(){return[{type:s}]},c);function c(e){this._errorMessageSrv=e,this._cachedCleanMessage=null,this._cachedTransformedMessage=null}var u=(d.forRoot=function(e){return{ngModule:d,providers:[e,s]}},d.decorators=[{type:r.NgModule,args:[{declarations:[i],exports:[i]}]}],d);function d(){}e.NgErrorMessageService=s,e.NgErrorMessageLoader=t,e.NgErrorMessageLoaderService=o,e.NgErrorMessageModule=u,e.ɵa=i,Object.defineProperty(e,"__esModule",{value:!0})}); //# sourceMappingURL=ng-error-message.umd.min.js.map