Liferay - Angular2 - 消耗Json服务

时间:2017-04-14 21:44:49

标签: json angular liferay

我尝试在Liferay 7中实现Angular 2.虽然基本设置有效,但我无法使用任何json服务。我想知道是否因为有许多404期望node_modules在/ web / guest下。请看例子。

http://localhost:8080/web/guest/node_modules/zone.js/dist/zone.js 404

另外http://localhost:8080/o/rc-choice-web/js/system.config.js 404(未找到)。这实际上是在/ meta-inf / resources / js。

我在portlet root下复制了node_modules。我有其他问题编译。

另外我们如何消费liferay json服务?我们如何通过httpget传递凭证?

有人可以帮帮我吗?

1 个答案:

答案 0 :(得分:0)

Liferay根本不需要节点模块。 无论你在Angular 2中构建什么,都要在tomcat中保存输出文件夹[dist]。

Zone.js - >负责Angular 2中的变更检测。 System.js->模块加载器。 因此,没有这一点,任何事情都无法奏效。

在Angular2中使用Liferay Web服务需要在头文件中使用基本的Auth test@liferay.com以及它在标题中的密码。

像这样。

let username: string = 'test@liferay.com';
let password: string = 'test';
contentHeaders.append('Accept', 'application/json');
contentHeaders.append('Content-Type', 'application/json');
contentHeaders.append("Authorization", "Basic " + btoa(username + ":" + password));