Assign id attribute to back button on ion-navbar


#1

Hi! My ionic application has been using the ion-navbar with the back button with no problem. When the button needs to be hidden, the hideBackButton property is used. However, i need to add an id to the button element to make the automated testing task easier. Since the back button itself is not explicitly on my HTML code, is there a way to add this id attribute through the ion-navbar? Or any other way for this?

Sample navbar:

 <ion-header class="standard-header">
   <ion-navbar>
     <ion-title id="page_title"><div innerHtml="{{ pageTitle }}"></div></ion-title>
   </ion-navbar>
 </ion-header>

I know also that the back button text can be specified through the Config parameter in the root app component for the IonicModule. Could it be somehow assign through this config?

 @NgModule({
  ...
  imports: [
     IonicModule.forRoot(MyApp, {statusbarPadding: false, backButtonText: '',scrollAssist: false}),
 ...

#2

See: https://alligator.io/angular/viewchild-access-component/