TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sujeet Raman
864
927
352.9k
Angular2 Cannot read property 'nativeElement' of undefined
Aug 2 2017 4:06 AM
I am trying to get datas from
component in html,one upload image function is there.
but am getting 'nativeElement' of undefined error.what mistake i did?
import { Component, OnInit, ElementRef } from '@angular/core';
public uploadImage(): void {
alert("file methode strike");
this.elem.nativeElement.querySelector('#spinner').style.visibility = 'visible';
let files = this.elem.nativeElement.querySelector('#selectFile').files;
let formData = new FormData();
let file = files[0];
formData.append('selectFile', file, file.name);
this._StartpageAdminservice.uploadImage(formData).subscribe(
res => this.dataLoaded(res));
console.log(this.dataLoaded);
private dataLoaded(data: any): void {
this.elem.nativeElement.querySelector('#spinner').style.visibility = 'hidden';
}
html(which is inside a
tag)
Name :
Link Url :
Image Upload :
Publish Start Date :
Publish End Date :
Save
Reply
Answers (
3
)
How to post and bind images that coming as BASE64 string
base64 image coming in [src] but not rendering in tthe UI