Angular 19 - ng serve not serving assets?

Discussão em 'Angular' iniciado por WombaT, Março 18, 2025.

  1. WombaT

    WombaT Guest

    I have newly started project in Angular 19 with default setting and just a few simple components. I'm trying to add picture in one place, created public folder at /src as it was missing and apparently this is new folder instead of assets. Full path to image is src/public/radom.webp

    Referenced it in template like this: <img mat-card-image ngSrc="/radom.webp" alt="Sad railroad" height="1024" width="1024"/> and it does not load, url localhost:4200/radom.webp returns 404 error.

    Tried also:

    ngSrc="radom.webp"
    ngSrc="/public/radom.webp"
    ngSrc="public/radom.webp"
    ngSrc="assets/radom.webp"
    ngSrc="/assets/radom.webp"
    ngSrc="src/radom.webp"
    ngSrc="/src/radom.webp"
    ngSrc="src/public/radom.webp"
    ngSrc="/src/public/radom.webp"
    ngSrc="radom"


    and with src attribute, all of that above returns 404.

    angular.json is unmodified, as it was generated by angular/cli:

    "assets": [
    {
    "glob": "**/*",
    "input": "public"
    }
    ]


    Restarted ng serve, cleared cache, nothing. Seriously running out of ideas, even throwing more or less random words and chat-gpt did not produce any usefull solution or even idea.

    In previous versions with assets folder it just worked every single time...

    Continue reading...

Compartilhe esta Página