AEM(cq5)在组件中使用信息 [英] AEM (cq5) Working with information within a component

查看:105
本文介绍了AEM(cq5)在组件中使用信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个组件,可以在其中获取有关其父资源的一些基本信息。

I have a component in which I am able to get some basic information about its parent resource.

var parent = granite.resource.getParent();

var parent = granite.resource.getParent();

我现在正尝试在组件的JavaScript中获取属性 path(parent.path),但是脚本中的数据不在HTML中,使组件具有路径属性。

I am now trying to get the property "path" (parent.path) within the JavaScript that accompanies my component however the data is not available inside the script but within the HTML that renders the component the property "path" is available.

有人可以说明为什么在HTML而不是JavaScript中可以实现吗?

Could some one shine some light on why it is possible within the HTML but not the JavaScript?

推荐答案

为了获取路径,我必须按照@Bambara的说明使用 currentNode.getParent()。path。

In order to get the path I had to use "currentNode.getParent().path" per @Bambara's instructions.

var parent = currentNode.getParent();
var path = parent.path;

这篇关于AEM(cq5)在组件中使用信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆