Why won't angularjs interpret my object accurately?

Currently, I am in the process of developing an angularjs application and I have encountered a minor issue. The problem arises when I populate a list of projects and then apply filtering based on certain conditions. Visually, everything appears fine on the webpage without any apparent issues.

However, upon inspecting the console in Chrome, I noticed the following error when the page loads:

GET http://localhost:8000/app/img/customers/%7B%7Bproject.LogoPath%7D%7D 404 (Not Found) jquery-1.9.1.js:6063
GET http://localhost:8000/app/img/customers/%7B%7Bproject.LogoPath%7D%7D 404 (Not Found) angular-scenario.js:11101

It seems to display the first GET error, then execute the groupBy filter (twice), and finally, the second GET error appears.

The intriguing part is that the webpage displays everything correctly without any missing logos or undefined project errors.

Below is the code snippet responsible for generating the image path:

<article ng-repeat="pm in projects|filter:colorFilter|groupBy:'LeadProjectManagerName'">
    <section class="project-section-header">
        <h3>{{pm}} <small>{{(projects|filter:pm|filter:{ColorStatus:colorFilter}).length}} projects</small></h3>
    </section>
    <div class="project project-{{project.ColorStatus}}" ng-class="{'project-last':($index+1) % 4 == 0}" ng-repeat="project in projects|filter:pm|filter:{ColorStatus:colorFilter}">
        <img src="img/customers/{{project.LogoPath}}" class="project-logo">
        <h1><a href="#/project/{{project.Id}}/dashboard">{{project.Name}}</a></h1>
        <p class="project-progress">{{(project.CompletedTasks / project.ScheduledTasks) * 100 || 0}}%</p>
        <p class="project-icons"><i class="icon-ok"></i> {{project.CompletedTasks}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i class="icon-calendar"></i> {{project.ScheduledTasks}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i class="icon-remove"></i> {{project.MissedTasks}} </p>
    </div>
</article>

Despite the error message, all data and logos are being displayed correctly on the page. I am perplexed by the origin of this error and why it displays "project.LogoPath" literally instead of its value.

Any insights or solutions?

Answer №1

In order to properly handle the {{ variables.of.scope }}, you must utilize the ng-href directive. Otherwise, it will interpret it as a plain string. The same concept applies to the ng-src directive.

Answer №2

make sure to replace src with ng-src

<article ng-repeat="pm in projects|filter:colorFilter|groupBy:'LeadProjectManagerName'">
    <section class="project-section-header">
        <h3>{{pm}} <small>{{(projects|filter:pm|filter:{ColorStatus:colorFilter}).length}} projects</small></h3>
    </section>
    <div class="project project-{{project.ColorStatus}}" ng-class="{'project-last':($index+1) % 4 == 0}" ng-repeat="project in projects|filter:pm|filter:{ColorStatus:colorFilter}">
        <img ng-src="img/customers/{{project.LogoPath}}" class="project-logo">
        <h1><a href="#/project/{{project.Id}}/dashboard">{{project.Name}}</a></h1>
        <p class="project-progress">{{(project.CompletedTasks / project.ScheduledTasks) * 100 || 0}}%</p>
        <p class="project-icons"><i class="icon-ok"></i> {{project.CompletedTasks}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i class="icon-calendar"></i> {{project.ScheduledTasks}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i class="icon-remove"></i> {{project.MissedTasks}} </p>
    </div>
</article>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the most effective method to prevent the auto-complete drop-down from repeating the same value multiple times?

My search form utilizes AJAX to query the database for similar results as the user types, displaying them in a datalist. However, I encountered an issue where it would keep appending matches that had already been found. For example: User types: "d" Datali ...

Puppeteer: effective method for identifying and interacting with frequent popups in a loop

Seeking assistance in handling multiple popup windows simultaneously. Referencing the code snippet below: const newPagePromise = new Promise(res => browser.on('targetcreated', target => res(target.page()))); for(const dataWorkSheet ...

The dropdown menu fails to function when placed within a div or generated dynamically

When I try to utilize the "dropdown-menu" outside of a div, it works correctly. However, when it is placed inside a div or added dynamically, it does not work as intended. Here is an example on jsfiddle The code snippet is as follows: <link rel="s ...

Guide on how to use Vue's watch feature to monitor a particular property within an array

I am interested in observing the "clientFilter" within an array TableProduit: [ { nr_commande: 0, date_creation: "", id_delegue: "1", clientFilter: "" } ], ...

Trigger Vue method when the size of a div element changes

Is there a way to trigger a method every time the dimensions (width or height) of a div element change? <template> <div> </div> </template> <script> export default { methods: { updateSize() { // ...

Is it possible to continuously loop and gradually fade the same image URL using JavaScript?

I have a dynamic image stored on my web server at example.com/webcam.jpg that is continuously updated by the server. My goal is to display this image on a static HTML page with a looping effect that smoothly transitions from the previous image to the upda ...

Compilation failure due to Typescript initialization issue

Encountering a TypeScript error in my IntelliJ-Idea 2017.1.1 IDE I have enabled JavaScript, NodeJS, and TypeScript Compiler. I have exhausted all solutions but the issue persists, perhaps I am missing something. Error: Initialization error (typescript ...

What makes the ng-file-upload Upload service so special?

Why do I need to use the Upload service with ng-file-upload in this specific way? Upload.upload({ url: '/postMyFormHere', data: { fileToUpload: model.file, someField1: model.field1, someField2: model.field2, ...

The SMTP request for a one.com domain email is experiencing issues when sent from the render.com server

I have set up an Express JS server on render.com to handle SMTP calls to an email service hosted on one.com with a custom domain. Utilizing nodemailer to manage the SMTP call: app.post("/send-mail", validate(schema), (req, res) => { console. ...

contenteditable -- Utilizing AngularJS to create a block element for the title only

When I click on an input field that is editable, I want the background color to change to white within the box. Can someone please assist me with this? Below is my code: HTML <div id="section{{section.index}}"> <h2 class="title" contentedit ...

"Looking for a way to automatically close the <li> tag in Vuejs when clicked outside

clickOutside: 0, methods: { outside: function(e) { this.clickOutside += 1 // eslint-disable-next-line console.log('clicked outside!') }, directives: { 'click-outside': { ...

Tips for customizing the back button in Ionic 3

<ion-header> <ion-navbar> <ion-buttons left> <button ion-button navPop icon-only> <ion-icon ios="ios-arrow-back" md="nbsons-arrow-back"></ion-icon> </button> </ion-buttons> <ion-title> ...

Is it possible to use Vuejs v-model for a complete form instead of individual inputs?

Note: This solution is applicable for Vue 2.X I am currently working on a unique Vue.js component that has the ability to generate "custom" forms. This component essentially functions as a standalone form with multiple input fields. Users have the option ...

show various commands and outcomes of the getElementsByClassName() function

Can someone help me figure out how to use the "getElementsByClassName() Method" in JavaScript to change or display different colors? I am trying to change the background color to blue for the class "ex" and red for the class "example", but it's not wo ...

Discovering a locator based on the initial portion of its value

Here's a piece of code that is used to click on a specific locator: await page.locator('#react-select-4-option-0').click(); Is there a way to click on a locator based on only the initial part of the code, like this: await page.locator(&apos ...

Different placeholder text rendered in two text styles

Can an input box placeholder have two different styles? Here's the design I have in mind: https://i.stack.imgur.com/7OH9A.png ...

Unable to export Interface in Typescript - the specific module does not offer an export named Settings

I am encountering an issue while trying to export/import an interface in Typescript. The error message I receive is causing confusion as I'm unsure of where I went wrong. Uncaught SyntaxError: The requested module '/src/types/settings.ts' ...

Issue with RouterLink not recognizing QueryParams

I have encountered an issue where dynamically generated URLs with queryParams inside [routerLink] are breaking routes. For example: this.url = '/question/ask?details=1' <a [routerLink]="url"> {{ data.name }}</a> Upon mouseover, the ...

Receive JSON data with camel-case in a Web API 2.0 using a model in pascal-case style

My attempt to execute a PUT call on my Web API involves configuring the WebApiConfig.cs file to send data back to my Web project in camel case format. config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesCont ...

Passing data to a different JS file

Is there a way to pass the values of two variables to another JS file? var publicPath = path.resolve(__dirname, '/src/login'); app.use(express.static(publicPath)); app.get('/auth', function (request, response) { response.sendFile(p ...