cancel
Showing results for 
Search instead for 
Did you mean: 

access DOM element inside template

nupurkul
Champ on-the-rise
Champ on-the-rise

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 ACCEPTED ANSWER

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

View answer in original post

6 REPLIES 6

dvuika
Star Collaborator
Star Collaborator

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 

nupurkul
Champ on-the-rise
Champ on-the-rise

Thanks.

eugenio_romano
Elite Collaborator
Elite Collaborator

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

I just want to change text on submit button

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

It worked. Thanks.