【发布时间】:2019-11-03 16:57:03
【问题描述】:
我正在尝试在 jsPanel 中加载一个 Angular 组件,但它还不能工作。 Chrome DevTools 总是显示<app-chat-tab></app-chat-tab> 而不是组件html,所以我认为它根本没有呈现。
这是我的代码:
export class ChatTabService {
jsPanel: any;
activeChats: ClientUser[];
constructor(@Inject(PLATFORM_ID) private platformId, private zone: NgZone) {
if (isPlatformBrowser(this.platformId)) {
this.jsPanel = require('node_modules/jspanel4/es6module/jspanel.min.js').jsPanel;
}
}
openChatWindow(toUser: ClientUser) {
if (!this.activeChats.find(u => u.id === toUser.id)) {
this.jsPanel.create({
theme: 'primary',
headerTitle: toUser.username,
position: 'center-top 0 58',
contentSize: '450 250',
content: '<app-chat-tab></app-chat-tab>',
callback() {
this.content.style.padding = '20px';
},
onbeforeclose() {
return confirm('Do you really want to close the panel?');
}
});
this.activeChats.push(toUser);
}
}
}
有什么想法吗?
【问题讨论】:
-
Angular 不允许你以这种方式这样做。具体来说,它不会将
app-chat-tab解析和实例化为角度组件 -
这很可悲,但我是这么认为的.. 有什么解决方法吗?
-
可能有,但我对jsPanel一无所知,抱歉。我只是想阻止你使用这种方法。