내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Update Component Depending on WCMMode in Angular

Avatar

Level 2

For various components we use, we have different output depending on whether the author is in edit mode or preview mode (or wcmmode is disabled altogether).  Is there an easy way to hook into this, such that we can leverage it when outputting content in an Angular template...and such that when it changes, we re-render the component?

 

I used the latest SPA archetype to generate my Angular project.

 

Thanks in advance!

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor and Adobe Champion

@evancooperman-s 

You can pass a property to your AngularJS component named "mode". The "mode" property can be set with either your Sling Models or pass the value directly with Sightly.

 

Sling Model:
@SlingObject
private SlingHttpServletRequest request;
WCMMode.fromRequest(request);

Sightly:
data-sly-test="${wcmmode.edit}"
data-sly-test="${wcmmode.preview}"
data-sly-test="${wcmmode.disabled}"
data-sly-test="${wcmmode.design}"

 

I hope this helps. 

원본 게시물의 솔루션 보기

2 답변 개

Avatar

Level 2

Hi,

AEM will create a cookie with name "wcmmode = (edit/preview)" if your page is opened in edit mode.

 

// Fetch cookie value and compare 
if (cookieValue === 'edit') {

//customcode
} else{

//customecode

}

 

Cookie in edit mode:

BaluM_0-1584785922821.png

 

Cokkie in preview mode:

BaluM_0-1584786425796.png

 

 

Avatar

정확한 답변 작성자:
Community Advisor and Adobe Champion

@evancooperman-s 

You can pass a property to your AngularJS component named "mode". The "mode" property can be set with either your Sling Models or pass the value directly with Sightly.

 

Sling Model:
@SlingObject
private SlingHttpServletRequest request;
WCMMode.fromRequest(request);

Sightly:
data-sly-test="${wcmmode.edit}"
data-sly-test="${wcmmode.preview}"
data-sly-test="${wcmmode.disabled}"
data-sly-test="${wcmmode.design}"

 

I hope this helps.