angular - 无法将模板文件用作 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:liferay-ce-portal-tomcat-7.3.2-ga3
- 节点:v8.12.0
- 角度/cli:^1.6.7
- 角度/编译器-cli:^5.0.0
- liferay-npm-bundler:2.18.2
- 打字稿:2.4.2
解决方案
我从 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 {}
推荐阅读
- machine-learning - Q学习,拉米游戏的状态,动作和奖励是什么?
- java - 无法将 FireBase 中的数据加载到 Recycler 视图中
- python - Python Web Scraping:Ahref 链接和文章未显示在源代码中
- if-statement - 展平嵌套数组
- php - 如何使 if else 条件在 .htaccess 中重定向
- ffmpeg - 将图像流转换为 H.264 实时视频流的过程是什么?
- django - 显示自定义成功或错误进度条
- google-apps-script - 优化空间?
- javascript - 在 javascript json 数组中搜索任何值,如搜索词
- java - 从字符串中删除字母