access DOM element inside template

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

access DOM element inside template

Jump to solution

Hi, I am new to Alfresco. I am developing a process in APS(Alfresco Process Services) for which I designed a form and submit button of this form triggers this process. Now, I used 'adf-start-form' component to display this form on browser using ADF. This template is referenced using #startForm template reference variable. (<adf-start-form  #startForm>). Now I want to access a DOM element (button) inside this form. I have tried following approaches: 

@ViewChild('startForm',{read: ElementRef})
btn: ElementRef;


ngAfterViewInit() {
console.log(this.btn.nativeElement.querySelector(".class of button").innerText);
}

and

@ViewChild('startForm')
startForm: StartFormComponent;

ngAfterViewInit() {
console.log(this.startForm.outcomesContainer.nativeElement.innerText);
}

But, none of them is working. Could you please suggest how to access a DOM element of the form. Thanks.

1 Solution

Accepted Solutions
Highlighted
Alfresco Employee

Re: access DOM element inside template

Jump to solution

you can use a custom outcome in the form editor of APS

View solution in original post

6 Replies
Highlighted
Alfresco Employee

Re: access DOM element inside template

Jump to solution

Form component has lot of APIs, the Form Service allows listening to most of the form events including Outcome clicks. Getting buttons in the "jQuery" way is not the right approach

alfresco-ng2-components/form.component.md at master · Alfresco/alfresco-ng2-components · GitHub 

alfresco-ng2-components/form.service.md at master · Alfresco/alfresco-ng2-components · GitHub 

Highlighted
Alfresco Employee

Re: access DOM element inside template

Jump to solution

Can I ask the reason why you are trying to access to the submit button? so what is the behavior that you want add?

Highlighted
Active Member

Re: access DOM element inside template

Jump to solution

I just want to change text on submit button

Highlighted
Alfresco Employee

Re: access DOM element inside template

Jump to solution

you can use a custom outcome in the form editor of APS

View solution in original post

Highlighted
Active Member

Re: access DOM element inside template

Jump to solution

It worked. Thanks.

Highlighted
Active Member

Re: access DOM element inside template

Jump to solution

Thanks.