UNPKG

@ngsm/title

Version:

<p align="center"> <a href="https://github.com/ng-sm"> <img src="https://avatars2.githubusercontent.com/u/64587411?s=150"> </a> </p> <p align="center"> Title module based on the @ngx-translate/core package. </p>

16 lines (14 loc) 3.54 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/common"),require("@angular/core"),require("@ngx-translate/core"),require("rxjs/operators"),require("@angular/platform-browser"),require("@angular/router")):"function"==typeof define&&define.amd?define("@ngsm/title",["exports","@angular/common","@angular/core","@ngx-translate/core","rxjs/operators","@angular/platform-browser","@angular/router"],e):e(((t=t||self).ngsm=t.ngsm||{},t.ngsm.title={}),t.ng.common,t.ng.core,t["@ngx-translate/core"],t.rxjs.operators,t.ng.platformBrowser,t.ng.router)}(this,(function(t,e,r,n,i,o,u){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */function a(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,i,o=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)u.push(n.value)}catch(t){i={error:t}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return u}function l(t){for(;t.firstChild;)t=t.firstChild;return t}function s(t){return t.title?t.title:"title.default"}function f(t){return"primary"===t.outlet}function c(t){return t?" | "+t:""}var p=function(){function t(t,e,r,n,i){this.titleConfig=t,this.title=e,this.router=r,this.activatedRoute=n,this.translateService=i,this.setConfigInitialValue(),this.init()}return t.prototype.setConfigInitialValue=function(){this.config=this.titleConfig||{suffix:""}},t.prototype.init=function(){var t=this;this.router.events.pipe(i.filter((function(t){return t instanceof u.NavigationEnd})),i.map((function(){return l(t.activatedRoute)})),i.filter(f),i.mergeMap((function(t){return t.data}))).subscribe((function(e){return t.setTitle(e)}))},t.prototype.setTitle=function(t){var e=this,r=this.config.suffix,n=s(t);this.translateService.get(function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(a(arguments[e]));return t}([n],r?[r]:[])).subscribe((function(t){e.title.setTitle(t[n]+" "+c(t[r]))}))},t.decorators=[{type:r.Injectable}],t.ctorParameters=function(){return[{type:void 0,decorators:[{type:r.Optional},{type:r.Inject,args:["titleConfig"]}]},{type:o.Title},{type:u.Router},{type:u.ActivatedRoute},{type:n.TranslateService}]},t}();var g=function(){function t(t){this.titleService=t}return t.forRoot=function(e){return{ngModule:t,providers:[{provide:"titleConfig",useValue:e}]}},t.decorators=[{type:r.NgModule,args:[{imports:[e.CommonModule,n.TranslateModule],providers:[p]}]}],t.ctorParameters=function(){return[{type:p}]},t}();t.DEFAULT_TITLE="title.default",t.TitleModule=g,t.TitleService=p,t.getLastActivatedRoute=l,t.getTitleKey=s,t.getTitleSuffix=c,t.isPrimary=f,t.ɵa=p,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=ngsm-title.umd.min.js.map