Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {
- Compiler, Component, ComponentRef, Injector, NgModule, NgModuleRef, ViewChild, ViewContainerRef
- } from '@angular/core';
- import { ActivatedRoute } from "@angular/router";
- import { FormsModule, NgForm } from "@angular/forms";
- import { HttpService } from './ht.service';
- @Component({
- selector: 'app-module-routing',
- templateUrl: './module-routing.component.html'
- })
- export class ModuleRoutingComponent {
- @ViewChild('vc', {read: ViewContainerRef}) vc: ViewContainerRef;
- private cmpRef: ComponentRef<any>;
- private module_name: string;
- private module_link: any;
- private module_links = [
- {"access": "salessalquoent", "link": "sales\/sales_order_entry.php?NewQuotation=Yes"},
- ];
- constructor(private compiler: Compiler,
- private injector: Injector,
- private m: NgModuleRef<any>,
- private route: ActivatedRoute,
- private httpService: HttpService) {}
- test() { //<-- Want to Call this function
- alert('function called successfully');
- }
- printPage(template, httpService, link) {
- const styles = [`input { width: 100px, display: block }`];
- const tmpCmp = Component({ template, styles }) (
- class {
- OnSubmit(form: NgForm) {
- console.log(form);
- this.ModuleRoutingComponent.test(); //<-- Want to call Parent Component function here
- httpService.getPage(link, form.value)
- .subscribe(
- data => this.instance.printPage(data, httpService, link)
- );
- return false;
- };
- }
- );
- const tmpModule = NgModule({
- imports: [FormsModule],
- declarations: [tmpCmp]
- })(class {});
- this.compiler.compileModuleAndAllComponentsAsync(tmpModule)
- .then((factories) => {
- const f = factories.componentFactories[0];
- this.cmpRef = f.create(this.injector, [], null, this.m);
- this.cmpRef.instance.name = 'someForm';
- this.vc.insert(this.cmpRef.hostView);
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement