0

I would like to show when a file is selected, in the input. Why isn't it showing? My code:

<input type="file" id="logo" name="logo" ng-model="service.logo" required="required"> <img ng-src="{{service.logo}}"> 

Here is a JSFiddle.

1

2 Answers 2

2

Because in this you are just taking the input from the user. You need to write code to open the file, read it and display on to the view. As you want to show the image when the user browses and selects it, you need to trigger the fileSelect. Also, look into this, I think this is what you want. How to read a file in AngularJS?

Sign up to request clarification or add additional context in comments.

Comments

1

Because the only thing that gets passed to value and thus ng-model of a file input is the file name

If you want a preview (before upload) you need to use FileReader API to read the file and parse it into a data url and pass that to an image element

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.