4

My code is as shown below:

test.html

<div class="q-img-container">
    <img id="q-order-img" src="../img/ic_truck.png" alt=""></img>
</div>

But it gives me following error:

"Unhandled Promise rejection:"
"Template parse errors:
Void elements do not have end tags "img" ("iv class="q-img-container">
                <img id="q-order-img" src="../img/ic_truck.png" alt="">[ERROR ->]</img>
            </div>

My directory structure is as follows:

---app
------img
----------ic_truck.png
------template
----------test.html

What am I missing here?

2
  • remove the end tag </img> Commented Sep 25, 2017 at 17:36
  • 1
    Yes, it worked. The above line in question worked fine in angular 1 , why it is rejected in angular2 Commented Sep 25, 2017 at 17:40

1 Answer 1

6

img tag is a void element. Such elements cannot have any content and are forbidden to be closed (W3C recommendation).

As the error message says, remove the end tag </img>.

Just use following

<img id="q-order-img" src="../img/ic_truck.png" alt="">

Please refer to this answer.

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.