可以使用Angular的字符串模板来指定出口名称。使用方括号括起来的属性绑定语法,将出口名称指定为组件属性的值。
例如,如果要使用字符串“myOutlet”作为出口名称,可以在模板中使用以下代码:
然后,在组件类中定义一个名为“myOutlet”的属性,并将其设置为字符串“myOutlet”。
@Component({
selector: 'my-app',
template: `
`
})
export class AppComponent {
myOutlet = "myOutlet";
myComponent = MyComponent;
}
这样,组件就会在指定的出口中呈现。
上一篇:Angular使用自定义XHR polyfill不起作用,因为“在zoneJS之外”。
下一篇:Angular使用自签名证书调用URI时失败,报错“net::ERR_CERT_AUTHORITY_INVALID”。