Angular view not showing dates retrieved from MySQL database

Currently, I am experimenting with Angularjs alongside TypeScript to create a simple to-do list as a web page for practice and fun. Below is my controller that interacts with the database and stores the objects:

module app.ToDo {

    class ToDoCtrl {
        toDoItems: app.domain.ToDoItems[];

        static $inject = ["dataAccessService"];
        constructor(private dataAccessService: app.common.DataAccessService)
        {
            this.toDoItems = [];

            var toDoResource = dataAccessService.getToDoResource();
            toDoResource.query((data: app.domain.ToDoItems[]) => {
                this.toDoItems = data;
            });
        }
    }

    angular.module("toDoManagement").controller("ToDoCtrl", ToDoCtrl);
}

Below is my ToDoItems class:

module app.domain {
    export class ToDoItems {
        constructor(public id: number, public title: string, public description: string,
        public due: Date, public completed: boolean) { }
    }
}

These are all of the fields present in my database. Here's a glimpse of my view:

<table>
    <thead>
        <tr>
            <td>Title</td>
            <td>Description</td>
            <td>Due Date</td>
            <td>Completed</td>
        </tr>
    </thead>
    <tbody ng-repeat="item in vm.toDoItems">
        <tr>
            <td>{{item.title}}</td>
            <td>{{item.description}}</td>
            <td>{{item.due}}</td>
            <td>{{item.completed}}</td>
        </tr>
    </tbody>
</table>

An issue arose where the Due column remained empty in each row. Could this be due to a formatting error while transitioning data from MySQL to JavaScript? Notably, the Due field within my database is of type DATE, not DATETIME.

SOLVED: The dilemma stemmed from a variable naming discrepancy, resulting in the value of Due being allocated to a non-existent variable in the class and inadvertently creating a new variable named due_Date. To rectify this, I simply adjusted the binding from {{item.due}} to {{item.due_Date}}.

Answer №1

Could using the date filter in Angular potentially solve this issue I'm facing?

{{ task.date | date : 'short' }}

This is simply my initial thought on a possible solution

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

Issue encountered with move_uploaded_file() function. An alert has been triggered stating that the file cannot be

Everything was running smoothly with my code when I was simply uploading files into the database. However, when I attempted to also store them in a folder, I encountered a warning: Warning: move_uploaded_file(): Unable to move 'F:\xammp\xam ...

Order information from three different databases using Codeigniter

I currently have three tables structured as follows, with primary keys highlighted and foreign keys in italic: projecttasks [ projecttasksid, projectstructureid, assignto, taskname ] projectstructure [projectstructureid, projectid, structurename] ...

The Sequelize hasMany function is functioning properly, however, there seems to be an issue with the inverse relationship not

Currently, I am delving into the world of MySQL relations within Node Js using Sequelize with Express Js. When I use User.hasMany(Post);, everything runs smoothly. However, issues arise when attempting to reverse it in the Post model with Post.belongsTo(Us ...

What is the discrepancy in the various calculations?

SELECT count(ProductID) as CountAllProducts, count(CASE WHEN PriceType = '1' THEN ProductID ELSE 0 END) as CountPriceType1, count(CASE WHEN PriceType = '2' THEN ProductID ELSE 0 END) as CountPriceType2 FROM Products We seem t ...

What is the approach to constructing an observable that triggers numerous observables depending on the preceding outcome?

One of my endpoints returns { ids: [1, 2, 3, 45] }, while the other endpoint provides values for a given id like { id: 3, value: 30, active: true }. I am currently attempting to create an observable that will call the first endpoint and then, for each id r ...

Unpredictable spikes in write speeds impacting a MySQL InnoDB table

I am experiencing a performance issue in my MySQL database. I have a table with simple numeric values. Here is the structure of the table: CREATE TABLE `_user_activity` ( `id` int NOT NULL AUTO_INCREMENT, `user_id` bigint NOT NULL, `jday` mediumint NOT ...

Ways to create animation solely using CSS for a div element

After spending hours searching for solutions, I still haven't found the perfect answer without using JQuery. I am attempting to add a slide-up animation effect to my divs. I have tried numerous options, including the simplest one: transition: all li ...

Copying elements from ng-repeat scope to outside

I am brand new to AngularJS and I've been trying to figure out a solution for quite some time now without any luck. Basically, I have a form where users can add new fields. These fields are then displayed in a list at the bottom using ng-repeat. When ...

How can I bind the ID property of a child component from a parent component in Angular 2 using @Input?

I have a unique requirement in my parent component where I need to generate a child component with a distinct ID, and then pass this ID into the child component. The purpose of passing the unique ID is for the child component to use it within its template. ...

Validation with React Hooks does not function properly when used on a controlled component

I've recently started using react hook form and I've created a custom component based on material ui's autocomplete. The issue I'm facing is that react hook form isn't validating the field at all. Let me show you how the setup look ...

TypeScript encounters a problem when attempting to concatenate arrays with different signature overloads

I encountered the following error message: There is an issue with overloading. Overload 1 of 2, '(...items: ConcatArray<{ title: string; width: number; dataIndex: string; render: (level: string) => Element; }>[]): { title: string; width: nu ...

Using React's useState hook with an empty array

interface Crumb { title: string; url: string; } interface Crumbies { crumbsArray: Crumb[]; } // component const [breadcrumbs, setBreadcrumbs] = useState<Crumbies>([]); I encountered an issue: TS2345: Argument of type 'never[]' is ...

Unable to achieve maximum image clarity using base64 encoding

** I have been able to save images in a remote MySQL database using the code provided. However, I am facing an issue with image quality as the images appear to be of very low quality. Can anyone offer a solution to improve the image quality? Thanks in adv ...

Angular Application for Attaching Files to SOAP Service

I am currently utilizing soap services to pass XML data along with file attachments. While SoapUI tool works perfectly for this purpose, I want to achieve the same functionality through Angular6 in my project. Below is a snippet of my Xml code. <soap ...

Troubleshooting issue with ng-pattern functionality in AngularJS

My regex pattern (http(s)?://)?([\w-]+\.)+[\w-]+(/[\w- ;,./?%&=]*)? works perfectly fine when checked using an online tool. However, when I use it in ng-pattern like this: ng-pattern="(http(s)?://)?([\w-]+\.)+[\w-]+(/ ...

Creating a TypeScript class that includes an input interface with the ability to have optional

Struggling with the compiler here and wondering if I'm on the wrong track or just pursuing a misguided approach. My goal is to have a class with required parameters, along with an input interface containing optional parameters. If a parameter is miss ...

The Highchart data series seems to be getting cut off

Can anyone assist me in creating a 24-hour data chart using Highcharts? I am encountering an issue where the first two data points are not rendering correctly, showing 11 columns instead of 12. I have provided an example here. Any help would be greatly a ...

Navigating through Expo with Router v3 tabs, incorporating stack navigation, search functionality, and showcasing prominent titles

I've been working on designing a navigation header similar to the Apple Contacts app, with a large title and search function, but only for the Home Screen. All other tabs should have their own unique settings, like different titles or hidden navigatio ...

String encodings that are not formatted properly

After extensive research on PHP, UTF-8, and character encoding techniques, my question pertains to rectifying data that was inserted prior to implementing proper character encoding practices. Currently, all connections are configured to use utf8 with PDO. ...

Leveraging a column named "prior" when working with PDO

In my Cakephp 3 project, I am trying to include a column named "before" in my Model. However, when attempting to create and save an Entity, I encountered the following error: [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1064 You ha ...