Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49227

@ViewChild undefined

$
0
0

@cnswico wrote:

Before you judge, I’ll let you know that I’ve checked every single search result that popped out to no avail.

I’m trying to get an HTML5 Audio Element to autoplay upon page enter.
page-page.html:

<audio #audio id="audio" controls controlsList="nodownload">
   <source [src]="audioUrl" type="audio/mpeg">
   Sum Ting Wong.
</audio>

page-component.ts:

import { Component, ViewChild, ElementRef } from '@angular/core';

@IonicPage()
@Component({
  selector: 'page-page-page',
  templateUrl: 'page-page.html',
})
export class PagePage {
   @ViewChild('audio') elemElem;
   ...
   ngAfterViewInit () {
      console.log(this.elemElem); // Is always undefined.
   }
}

I don’t know why it’s always undefined. I’ve tried things like using the @ViewChild() within ngAfterViewInit() but of course, it’s not allowed.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49227

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>