首页 > 解决方案 > 无法将模板文件用作 Liferay Angular Portlet 中组件的模板

问题描述

无法将模板文件用作 Liferay angular portlet 中组件的模板。相同的语法适用于普通的 Angular 应用程序。

app.component.ts

import { Component } from '@angular/core';

@Component({
    templateUrl: './app.component.html'
    /*
     * I've tried to pass template file path as below but it wasn't worked
     * templateUrl: './app.component.html'
     * templateUrl: './app.component'
     * templateUrl: 'app.component.html'
     * templateUrl: 'app.component'
     */
})

export class AppComponent {}

app.component.html

<h1>app component loaded using template file.</h1>

下面是我的环境细节

无法将模板文件用作 Liferay Angular Portlet 中组件的模板

标签: angulartypescriptliferayportletliferay-7

解决方案


我从 Liferay 论坛找到了解决方案:https ://liferay.dev/forums/-/message_boards/message/103176934#_com_liferay_message_boards_web_portlet_MBPortlet_message_106877078

根据描述,我已经更新了 templateUrl 路径,如下所示,它工作正常。

app.component.ts

import { Component } from '@angular/core';

@Component({
    templateUrl: '/o/student-crud-portlet/lib/app/app.component.html'
})

export class AppComponent {}

推荐阅读