angular-cn/aio/dist/generated/docs/api/common/NgComponentOutlet.json

5 lines
35 KiB
JSON

{
"id": "api/common/NgComponentOutlet",
"title": "NgComponentOutlet",
"contents": "\n\n<article>\n <div class=\"breadcrumb-container\">\n <div class=\"breadcrumb\">\n <script type=\"application/ld+json\">\n {\n \"@context\": \"http://schema.org\",\n \"@type\": \"BreadcrumbList\",\n \"itemListElement\": [\n { \"@type\": \"ListItem\", \"position\": 1, \"item\": { \"@id\": \"https://angular.io//api\", \"name\": \"API\" } },\n { \"@type\": \"ListItem\", \"position\": 2, \"item\": { \"@id\": \"https://angular.io/api/common\", \"name\": \"@angular/common\" } },\n { \"@type\": \"ListItem\", \"position\": 3, \"item\": { \"@id\": \"https://angular.io/api/common/NgComponentOutlet\", \"name\": \"NgComponentOutlet\" } }\n ]\n }\n </script>\n <a href=\"/api\">API</a> > <a href=\"api/common\">@angular/common</a>\n </div>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/directives/ng_component_outlet.ts?message=docs(common)%3A%20describe%20your%20change...#L10-L116\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/directives/ng_component_outlet.ts#L10-L116\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n \n <header class=\"api-header\">\n <h1 id=\"ngcomponentoutlet\">NgComponentOutlet<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/NgComponentOutlet#ngcomponentoutlet\"><i class=\"material-icons\">link</i></a></h1>\n \n <label class=\"api-type-label directive\">directive</label>\n \n \n \n </header>\n \n <aio-toc class=\"embedded\"></aio-toc>\n\n <div class=\"api-body\">\n \n <section class=\"short-description\">\n <p>Instantiates a single <a href=\"api/core/Component\"><code>Component</code></a> type and inserts its Host View into current View.\n<code><a href=\"api/common/NgComponentOutlet\" class=\"code-anchor\">NgComponentOutlet</a></code> provides a declarative approach for dynamic component creation.</p>\n\n <p><a href=\"api/common/NgComponentOutlet#description\">See more...</a></p>\n </section>\n \n \n \n \n\n <h2 id=\"ngmodule\">NgModule<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/NgComponentOutlet#ngmodule\"><i class=\"material-icons\">link</i></a></h2>\n<ul class=\"ngmodule-list\">\n\n <li>\n <a href=\"api/common/CommonModule\">\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box\">CommonModule</code-example>\n </a>\n </li>\n \n</ul>\n\n\n \n<section class=\"selector-list\">\n <h2 id=\"selectors\">Selectors<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/NgComponentOutlet#selectors\"><i class=\"material-icons\">link</i></a></h2>\n \n <ul>\n <li><code>[<a href=\"api/common/NgComponentOutlet\" class=\"code-anchor\">ngComponentOutlet</a>]</code></li>\n \n </ul>\n \n</section>\n\n\n\n \n\n<section class=\"instance-properties\">\n <h2 id=\"properties\">Properties<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/NgComponentOutlet#properties\"><i class=\"material-icons\">link</i></a></h2>\n <table class=\"is-full-width list-table property-table\">\n <thead>\n <tr>\n <th>Property</th>\n <th>Description</th>\n </tr>\n </thead>\n <tbody>\n \n <tr class=\"instance-property\">\n <td>\n <a id=\"ngComponentOutlet\"></a>\n <code class=\"\"><span class=\"property-binding\">@<a href=\"api/core/Input\" class=\"code-anchor\">Input</a>()</span><br><span class=\"member-name\"><a href=\"api/common/NgComponentOutlet\" class=\"code-anchor\">ngComponentOutlet</a></span>: <a href=\"api/core/Type\" class=\"code-anchor\">Type</a>&#x3C;any></code>\n </td>\n <td>\n \n \n \n </td>\n </tr>\n \n <tr class=\"instance-property\">\n <td>\n <a id=\"ngComponentOutletInjector\"></a>\n <code class=\"\"><span class=\"property-binding\">@<a href=\"api/core/Input\" class=\"code-anchor\">Input</a>()</span><br><span class=\"member-name\">ngComponentOutletInjector</span>: <a href=\"api/core/Injector\" class=\"code-anchor\">Injector</a></code>\n </td>\n <td>\n \n \n \n </td>\n </tr>\n \n <tr class=\"instance-property\">\n <td>\n <a id=\"ngComponentOutletContent\"></a>\n <code class=\"\"><span class=\"property-binding\">@<a href=\"api/core/Input\" class=\"code-anchor\">Input</a>()</span><br><span class=\"member-name\">ngComponentOutletContent</span>: any[][]</code>\n </td>\n <td>\n \n \n \n </td>\n </tr>\n \n <tr class=\"instance-property\">\n <td>\n <a id=\"ngComponentOutletNgModuleFactory\"></a>\n <code class=\"\"><span class=\"property-binding\">@<a href=\"api/core/Input\" class=\"code-anchor\">Input</a>()</span><br><span class=\"member-name\">ngComponentOutletNgModuleFactory</span>: <a href=\"api/core/NgModuleFactory\" class=\"code-anchor\">NgModuleFactory</a>&#x3C;any></code>\n </td>\n <td>\n \n \n \n </td>\n </tr>\n \n </tbody>\n </table>\n</section>\n\n\n\n \n\n\n \n <section class=\"description\">\n <h2 id=\"description\">Description<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/NgComponentOutlet#description\"><i class=\"material-icons\">link</i></a></h2>\n <p><code><a href=\"api/common/NgComponentOutlet\" class=\"code-anchor\">NgComponentOutlet</a></code> requires a component type, if a falsy value is set the view will clear and\nany existing component will get destroyed.</p>\n\n <h3 id=\"fine-tune-control\">Fine tune control<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/NgComponentOutlet#fine-tune-control\"><i class=\"material-icons\">link</i></a></h3>\n<p>You can control the component creation process by using the following optional attributes:</p>\n<ul>\n<li>\n<p><code>ngComponentOutletInjector</code>: Optional custom <a href=\"api/core/Injector\"><code>Injector</code></a> that will be used as parent for\nthe Component. Defaults to the injector of the current view container.</p>\n</li>\n<li>\n<p><code>ngComponentOutletContent</code>: Optional list of projectable nodes to insert into the content\nsection of the component, if exists.</p>\n</li>\n<li>\n<p><code>ngComponentOutletNgModuleFactory</code>: Optional module factory to allow dynamically loading other\nmodule, then load a component from that module.</p>\n</li>\n</ul>\n<h3 id=\"syntax\">Syntax<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/NgComponentOutlet#syntax\"><i class=\"material-icons\">link</i></a></h3>\n<p>Simple</p>\n<code-example>\n&#x3C;ng-container *<a href=\"api/common/NgComponentOutlet\" class=\"code-anchor\">ngComponentOutlet</a>=\"componentTypeExpression\">&#x3C;/ng-container>\n</code-example>\n<p>Customized injector/content</p>\n<code-example>\n&#x3C;ng-container *<a href=\"api/common/NgComponentOutlet\" class=\"code-anchor\">ngComponentOutlet</a>=\"componentTypeExpression;\n injector: injectorExpression;\n content: contentNodesExpression;\">\n&#x3C;/ng-container>\n</code-example>\n<p>Customized ngModuleFactory</p>\n<code-example>\n&#x3C;ng-container *<a href=\"api/common/NgComponentOutlet\" class=\"code-anchor\">ngComponentOutlet</a>=\"componentTypeExpression;\n ngModuleFactory: moduleFactory;\">\n&#x3C;/ng-container>\n</code-example>\n<h3 id=\"a-simple-example\">A simple example<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/NgComponentOutlet#a-simple-example\"><i class=\"material-icons\">link</i></a></h3>\n<code-example path=\"common/ngComponentOutlet/ts/module.ts\" region=\"SimpleExample\">\n@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>({selector: 'hello-world', template: 'Hello World!'})\nexport class HelloWorld {\n}\n\n@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>({\n selector: 'ng-component-outlet-simple-example',\n template: `&#x3C;ng-container *<a href=\"api/common/NgComponentOutlet\" class=\"code-anchor\">ngComponentOutlet</a>=\"HelloWorld\">&#x3C;/ng-container>`\n})\nexport class NgComponentOutletSimpleExample {\n // This field is necessary to expose HelloWorld to the template.\n HelloWorld = HelloWorld;\n}\n\n</code-example>\n<p>A more complete example with additional options:</p>\n<code-example path=\"common/ngComponentOutlet/ts/module.ts\" region=\"CompleteExample\">\n@<a href=\"api/core/Injectable\" class=\"code-anchor\">Injectable</a>()\nexport class Greeter {\n suffix = '!';\n}\n\n@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>({\n selector: 'complete-component',\n template: `Complete: &#x3C;ng-content>&#x3C;/ng-content> &#x3C;ng-content>&#x3C;/ng-content>{{ greeter.suffix }}`\n})\nexport class CompleteComponent {\n constructor(public greeter: Greeter) {}\n}\n\n@<a href=\"api/core/Component\" class=\"code-anchor\">Component</a>({\n selector: 'ng-component-outlet-complete-example',\n template: `\n &#x3C;ng-container *<a href=\"api/common/NgComponentOutlet\" class=\"code-anchor\">ngComponentOutlet</a>=\"CompleteComponent;\n injector: myInjector;\n content: myContent\">&#x3C;/ng-container>`\n})\nexport class NgComponentOutletCompleteExample {\n // This field is necessary to expose CompleteComponent to the template.\n CompleteComponent = CompleteComponent;\n myInjector: <a href=\"api/core/Injector\" class=\"code-anchor\">Injector</a>;\n\n myContent = [[document.createTextNode('Ahoj')], [document.createTextNode('Svet')]];\n\n constructor(injector: <a href=\"api/core/Injector\" class=\"code-anchor\">Injector</a>) {\n this.myInjector =\n Injector.create({providers: [{provide: Greeter, deps: []}], parent: injector});\n }\n}\n\n</code-example>\n\n </section>\n \n\n \n\n \n\n \n\n<section class=\"instance-methods\">\n <h2 id=\"methods\">Methods<a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/NgComponentOutlet#methods\"><i class=\"material-icons\">link</i></a></h2>\n \n <a id=\"ngOnChanges\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"ngonchanges\">\n ngOnChanges()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/NgComponentOutlet#ngonchanges\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/directives/ng_component_outlet.ts?message=docs(common)%3A%20describe%20your%20change...#L82-L111\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/directives/ng_component_outlet.ts#L82-L111\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n \n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">ngOnChanges</span>(changes: <a href=\"api/core/SimpleChanges\" class=\"code-anchor\">SimpleChanges</a>)</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters\">Parameters</h6>\n <table class=\"is-full-width list-table parameters-table instance-method-overload-parameters\">\n <tbody>\n \n <tr class=\"instance-method-overload-parameter\">\n <td class=\"param-name\">\n <a id=\"\"></a>\n <code>changes</code>\n </td>\n <td class=\"param-type\"><code><a href=\"api/core/SimpleChanges\" class=\"code-anchor\">SimpleChanges</a></code></td>\n <td class=\"param-description\">\n \n \n </td>\n </tr>\n </tbody>\n</table>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n <a id=\"ngOnDestroy\"></a>\n<table class=\"is-full-width method-table instance-method\">\n <thead><tr><th>\n <div class=\"with-github-links\">\n <h3 id=\"ngondestroy\">\n ngOnDestroy()\n \n <a title=\"Link to this heading\" class=\"header-link\" aria-hidden=\"true\" href=\"api/common/NgComponentOutlet#ngondestroy\"><i class=\"material-icons\">link</i></a></h3>\n <div class=\"github-links\">\n <a href=\"https://github.com/angular/angular/edit/master/packages/common/src/directives/ng_component_outlet.ts?message=docs(common)%3A%20describe%20your%20change...#L112-L115\" aria-label=\"Suggest Edits\" title=\"Suggest Edits\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">mode_edit</i></a>\n <a href=\"https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/directives/ng_component_outlet.ts#L112-L115\" aria-label=\"View Source\" title=\"View Source\"><i class=\"material-icons\" aria-hidden=\"true\" role=\"img\">code</i></a>\n</div>\n </div>\n </th></tr></thead>\n <tbody>\n \n \n <tr>\n <td>\n <div class=\"overload-info\">\n \n\n <code-example language=\"ts\" hidecopy=\"true\" class=\"no-box api-heading\"><span class=\"member-name\">ngOnDestroy</span>()</code-example>\n\n \n\n <h6 class=\"no-anchor\" id=\"parameters-1\">Parameters</h6>\n <p>There are no parameters.</p>\n\n \n\n\n \n\n \n</div>\n </td>\n </tr>\n \n\n \n\n \n </tbody>\n</table>\n\n \n</section>\n\n \n \n \n\n </div>\n</article>\n\n<!-- links to this doc:\n - api/common\n - api/common/CommonModule\n - api/core/OnChanges\n - api/core/OnDestroy\n-->\n<!-- links from this doc:\n - /api\n - api/common\n - api/common/CommonModule\n - api/common/NgComponentOutlet#a-simple-example\n - api/common/NgComponentOutlet#description\n - api/common/NgComponentOutlet#fine-tune-control\n - api/common/NgComponentOutlet#methods\n - api/common/NgComponentOutlet#ngcomponentoutlet\n - api/common/NgComponentOutlet#ngmodule\n - api/common/NgComponentOutlet#ngonchanges\n - api/common/NgComponentOutlet#ngondestroy\n - api/common/NgComponentOutlet#properties\n - api/common/NgComponentOutlet#selectors\n - api/common/NgComponentOutlet#syntax\n - api/core/Component\n - api/core/Injectable\n - api/core/Injector\n - api/core/Input\n - api/core/NgModuleFactory\n - api/core/SimpleChanges\n - api/core/Type\n - https://github.com/angular/angular/edit/master/packages/common/src/directives/ng_component_outlet.ts?message=docs(common)%3A%20describe%20your%20change...#L10-L116\n - https://github.com/angular/angular/edit/master/packages/common/src/directives/ng_component_outlet.ts?message=docs(common)%3A%20describe%20your%20change...#L112-L115\n - https://github.com/angular/angular/edit/master/packages/common/src/directives/ng_component_outlet.ts?message=docs(common)%3A%20describe%20your%20change...#L82-L111\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/directives/ng_component_outlet.ts#L10-L116\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/directives/ng_component_outlet.ts#L112-L115\n - https://github.com/angular/angular/tree/12.0.0-next.7/packages/common/src/directives/ng_component_outlet.ts#L82-L111\n-->"
}