p3x-angular-compile
Advanced tools
Comparing version 4.1.337-32 to 4.1.345-36
@@ -1,2 +0,2 @@ | ||
import { ViewContainerRef, OnInit, OnChanges, SimpleChanges, Type, ModuleWithProviders } from '@angular/core'; | ||
import { ViewContainerRef, OnInit, OnChanges, SimpleChanges, Type, ModuleWithProviders, NgModule } from '@angular/core'; | ||
import { CompileService } from './CompileService'; | ||
@@ -8,2 +8,3 @@ export declare class CompileAttribute implements OnInit, OnChanges { | ||
context: any; | ||
module: NgModule; | ||
imports: Array<Type<any> | ModuleWithProviders | any[]>; | ||
@@ -10,0 +11,0 @@ update(): Promise<void>; |
@@ -65,3 +65,4 @@ "use strict"; | ||
context: this.context, | ||
imports: this.imports | ||
imports: this.imports, | ||
module: this.module | ||
})]; | ||
@@ -105,2 +106,3 @@ case 1: | ||
'context': [{ type: core_1.Input, args: ['p3x-compile-ctx',] },], | ||
'module': [{ type: core_1.Input, args: ['p3x-compile-module',] },], | ||
'imports': [{ type: core_1.Input, args: ['p3x-compile-imports',] },], | ||
@@ -124,2 +126,4 @@ }; | ||
/** @type {?} */ | ||
CompileAttribute.prototype.module; | ||
/** @type {?} */ | ||
CompileAttribute.prototype.imports; | ||
@@ -126,0 +130,0 @@ /** @type {?} */ |
@@ -1,1 +0,1 @@ | ||
[{"__symbolic":"module","version":3,"metadata":{"CompileAttribute":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[p3x-compile]"}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"html":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile"]}]}],"context":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile-ctx"]}]}],"imports":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile-imports"]}]}],"update":[{"__symbolic":"method"}],"ngOnInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ViewContainerRef"},{"__symbolic":"reference","module":"./CompileService","name":"CompileService"}]}]}}}},{"__symbolic":"module","version":1,"metadata":{"CompileAttribute":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[p3x-compile]"}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"html":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile"]}]}],"context":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile-ctx"]}]}],"imports":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile-imports"]}]}],"update":[{"__symbolic":"method"}],"ngOnInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ViewContainerRef"},{"__symbolic":"reference","module":"./CompileService","name":"CompileService"}]}]}}}}] | ||
[{"__symbolic":"module","version":3,"metadata":{"CompileAttribute":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[p3x-compile]"}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"html":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile"]}]}],"context":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile-ctx"]}]}],"module":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile-module"]}]}],"imports":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile-imports"]}]}],"update":[{"__symbolic":"method"}],"ngOnInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ViewContainerRef"},{"__symbolic":"reference","module":"./CompileService","name":"CompileService"}]}]}}}},{"__symbolic":"module","version":1,"metadata":{"CompileAttribute":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive"},"arguments":[{"selector":"[p3x-compile]"}]},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable"}}],"members":{"html":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile"]}]}],"context":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile-ctx"]}]}],"module":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile-module"]}]}],"imports":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input"},"arguments":["p3x-compile-imports"]}]}],"update":[{"__symbolic":"method"}],"ngOnInit":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ViewContainerRef"},{"__symbolic":"reference","module":"./CompileService","name":"CompileService"}]}]}}}}] |
@@ -1,2 +0,2 @@ | ||
import { Compiler, ViewContainerRef, ModuleWithProviders, Type } from '@angular/core'; | ||
import { NgModule, Compiler, ViewContainerRef, ModuleWithProviders, Type } from '@angular/core'; | ||
export interface CompileOptions { | ||
@@ -9,2 +9,3 @@ template: string; | ||
onError?: Function; | ||
module?: NgModule; | ||
} | ||
@@ -11,0 +12,0 @@ export declare class CompileService { |
@@ -39,2 +39,4 @@ "use strict"; | ||
var core_1 = require("@angular/core"); | ||
var common_1 = require("@angular/common"); | ||
var platform_browser_1 = require("@angular/platform-browser"); | ||
var /** @type {?} */ cache = {}; | ||
@@ -114,3 +116,3 @@ var CompileService = (function () { | ||
} | ||
var TemplateComponent, TemplateModule, component, factory; | ||
var TemplateComponent, module, TemplateModule, component, factory; | ||
return __generator(this, function (_a) { | ||
@@ -133,2 +135,25 @@ switch (_a.label) { | ||
TemplateComponent.ctorParameters = function () { return []; }; | ||
if (opts.module !== undefined && opts.imports !== undefined) { | ||
console.warn("opts.module and opts.imports collision, opts.module overrides opts.imports, it works, but you should make sure use only either module or imports :)"); | ||
} | ||
if (opts.module !== undefined) { | ||
module = Object.assign({}, opts.module); | ||
if (module.declarations === undefined) { | ||
module.declarations = [ | ||
TemplateComponent | ||
]; | ||
} | ||
else { | ||
module.declarations.push(TemplateComponent); | ||
} | ||
} | ||
else { | ||
module = { | ||
imports: opts.imports, | ||
declarations: [TemplateComponent] | ||
}; | ||
} | ||
module.imports = module.imports || []; | ||
module.imports.push(common_1.CommonModule); | ||
module.imports.push(platform_browser_1.BrowserModule); | ||
TemplateModule = (function () { | ||
@@ -140,6 +165,3 @@ function TemplateModule() { | ||
TemplateModule.decorators = [ | ||
{ type: core_1.NgModule, args: [{ | ||
imports: opts.imports, | ||
declarations: [TemplateComponent] | ||
},] }, | ||
{ type: core_1.NgModule, args: [module,] }, | ||
]; | ||
@@ -146,0 +168,0 @@ /** |
{ | ||
"name": "p3x-angular-compile", | ||
"version": "4.1.337-32", | ||
"version": "4.1.345-36", | ||
"corifeus": { | ||
@@ -37,4 +37,4 @@ "prefix": "p3x-", | ||
"devDependencies": { | ||
"corifeus-builder-angular": "^4.1.351-42", | ||
"corifeus-web": "^4.1.339-43" | ||
"corifeus-builder-angular": "^4.1.356-45", | ||
"corifeus-web": "^4.1.344-46" | ||
}, | ||
@@ -41,0 +41,0 @@ "dependencies": {}, |
@@ -79,13 +79,38 @@ [//]: #@corifeus-header | ||
If you want custom angular modules: | ||
```html | ||
<div [p3x-compile]="string" | ||
[p3x-compile-ctx]="youGetAContextToDoWithItAnything" | ||
[p3x-compile-module]="ngModule"> | ||
</div> | ||
``` | ||
### Options | ||
The templates are cached. | ||
Reference for module settings: | ||
https://github.com/angular/angular/blob/master/packages/core/src/metadata/ng_module.ts | ||
```typescript | ||
export interface CompileOptions { | ||
// cached by template | ||
template: string; | ||
container: ViewContainerRef; | ||
context?: any, | ||
// either imports or modules, don't use both | ||
// modules overrides imports | ||
imports?: Array<Type<any> | ModuleWithProviders | any[]>; | ||
context?: any, | ||
// you can customize here any you want to | ||
// CommonModule, BrowserModule are auto added | ||
// (like *ngIf and angular default directives) | ||
module?: NgModule; | ||
onCompiled?: Function, | ||
onError?: Function; | ||
} | ||
@@ -120,3 +145,3 @@ ``` | ||
--- | ||
[**P3X-ANGULAR-COMPILE**](https://pages.corifeus.tk/angular-compile) Build v4.1.336-32 | ||
[**P3X-ANGULAR-COMPILE**](https://pages.corifeus.tk/angular-compile) Build v4.1.344-36 | ||
@@ -123,0 +148,0 @@ [Corifeus](http://www.corifeus.tk) by [Patrik Laszlo](http://patrikx3.tk) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
48123
444
150