The functionality of Angular UI TimePicker is not functioning as expected

Currently, I am in the process of developing an angular directive that is designed to manage date and time functions. I have integrated Angular's UI Bootstrap into my project but have encountered a peculiar issue with the TimePicker component. While the TimePicker initially displays the starting time (set to the current time by default), attempting to adjust the time using the up/down arrows results in both fields showing 'NaN,' and upon inspecting the date, it indicates an invalid date format. Below is the snippet of my code:

utilisyncApp.directive("questionDateTime", [
    "$log",
    function ($log) {
        return {
            restrict: "E",
            templateUrl: "/app/directives/utilisyncItem/utilisyncQuestion/questionDateTime/questionDateTime.html",
            scope: {
                item: '='
            },
            link: function ($scope, $element, $attrs) {
                $scope.mStep = 1;
                $scope.hStep = 1;
                $scope.dateFormat = 'dd-MMM-yyyy'
                $scope.popup = { isOpen: false };
                $scope.dateTime = { time: new Date() };

                $scope.openDate = openDate;
                $scope.changed = changed;


                init();

                function init() {
                    if ($scope.item.question.defaultToCurrent) {
                        $scope.dateTime.date = new Date();
                    }
                }

                function openDate() {
                    $scope.popup.isOpen = true;
                }

                function changed() {
                    var date = $scope.dateTime.date;
                    var time = $scope.dateTime.time;
                    if ($scope.item.question.includeTime) {
                        $scope.item.value = new Date(date.getFullYear(), date.getMonth(), date.getDay(), time.getHours(), time.getMinutes(), 0);
                    }
                    else {
                        $scope.item.value = new Date(date.getFullYear(), date.getMonth(), date.getDay(), 0, 0, 0);
                    }
                }
            }
        };
    }
]);
<div class="form-group">
    <p class="input-group">
        <input type="text" class="form-control" uib-datepicker-popup="{{dateFormat}}" ng-model="dateTime.date" ng-change="changed()" is-open="popup.isOpen" datepicker-options="dateOptions" close-text="Close" />
        <span class="input-group-btn">
            <button type="button" class="btn btn-default" ng-click="openDate()"><i class="glyphicon glyphicon-calendar"></i></button>
        </span>
    </p>
    <uib-timepicker ng-if="item.question.includeTime" ng-model="dateTime.date" readonly-input="true" ng-change="changed()" hour-step="hstep" minute-step="mstep" show-meridian="true"></uib-timepicker>
</div>

I am following the example from their website very closely, yet it appears not to be functioning correctly for me, and I cannot determine why.

Answer №1

There seems to be a mistake in this particular line:

<uib-timepicker ng-if="item.question.includeTime" ng-model="dateTime.date" readonly-input="true" ng-change="changed()" hour-step="hStep" minute-step="mStep" show-meridian="true"></uib-timepicker>

It appears that you have written

hour-step="hstep" minute-step="mstep"

instead of

hour-step="hStep" minute-step="mStep"

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

JavaScript function that reveals a block of text when clicked for multiple Div Class elements

I am attempting to create an Onclick event that will trigger when any of my div elements with the class "Clicker" is clicked. I am not proficient in JavaScript and need assistance on how to achieve this. I was able to make it work using document.getElement ...

Unexpected behavior encountered when using await with pg query in JavaScript

I am facing an issue with using the return of a query from a postgresSQL database. Instead of simply printing it, I need to use it in another function. The problem lies in the fact that the function returns before fully executing the code. async function c ...

Creating a custom inline style button in Froala Editor

As a UX Designer with experience in frontend development, I am currently working on an online editor proof of concept for a usability study. One of the key findings so far is that users are requesting a button that can automatically apply the corporate fon ...

sending information from a PHP form to a JavaScript window

Currently, I am in the process of developing a game using javascript and jquery. In this game, when a player interacts with another character, it triggers the opening of text from an external file using the window.open('') function. At the start ...

Create a unique V-MODEL for each index that I generate

How can I customize the V-MODEL for each object generated? I am developing a cupcake website where users can create multiple forms with just one submission. However, when generating two fields, the inputs of the second field are linked to the inputs of t ...

What is the best method for launching a new window or tab in AngularJS?

My ASP.NET application incorporates AngularJS, however, we are facing an issue where clicking on "edit" opens the new view in the same tab. Is there a way to open it in a new tab instead? Here's the code snippet: List.html: <td><a ng-click= ...

AngularJS controller utilizing dynamic variables (potentially services)

I am currently working on creating a simple HTML ad generator project to help me learn Angular. I feel like there might be a better approach for this, possibly involving a service or factory, but after spending hours brainstorming, I still can't figur ...

Error: TypeScript is unable to find the property URL within the specified type. Can you help

Currently, I am honing my skills in TypeScript and encountering a problem. I am a bit confused about how to define the type for the URL when I am setting the mix here. Obviously, the URL is supposed to be a string, and this specific scenario is within the ...

JQuery user interface dialog button

When using a jQuery UI dialog, I want to add tooltips to buttons. In my current code: buttons: { 'My Button' : function(e) { $(e.target).mouseover(function() { alert('test'); }); } This code triggers an action only a ...

Multiple instances of jQuery file being loaded repeatedly

Having an issue with the jQuery file (jquery-1.11.3.min.js) loading multiple times. It seems that other jQuery files in the index.html page might be causing this. Any advice on how to resolve this would be greatly appreciated. <script type="text/javasc ...

Having trouble accessing the record by clicking on a table cell

I'm attempting to dynamically click on a cell within a row by passing the text of the cell. Here is my code: await element.all(by.xpath('//div/table/tbody/tr')).then(rows => { rows.find(row => { return row.all(by.tagName(&apo ...

"Troubleshooting a Animation Problem in the Latest Version of

I have discovered an issue with animations on the latest version of Firefox Quantum. Upon loading a page with certain animated elements set to display: none;, when a script changes it to .display = "block";, some parts of the animation may be missed or no ...

Leveraging React's UseEffect() to retrieve information from GraphQL

I am currently attempting to retrieve data from graphQL. I understand that by placing a function inside the react UseEffect(), I can trigger the function once the data is updated and structured. However, while working on a chatroom feature, I am facing an ...

What causes Angular2 to detect both reference changes and primitive changes even when the OnPush flag is enabled?

Take a look at this code snippet import {Component, OnInit, Input, OnChanges, DoCheck, ChangeDetectionStrategy} from 'angular2/core' @Component({ selector: 'child1', template: ` <div>reference change for entire object: { ...

Setting a timer within Vuex - step by step guide

I recently delved into learning Vue and Vuex. My current project involves setting up a countdown timer that initiates a countdown from 5 seconds upon being clicked. The implementation logic resides in the Vuex store for efficient state management, but unfo ...

Callback functions in Node.js

I'm struggling to grasp the concept of a callback function. This is new territory for me, so please be patient as I try to learn. To dive in and experiment, I'm attempting to log in to Twitter using zombie.js. Consider the following example: va ...

Why is my jQuery SlideReveal not displaying on page load?

Can anyone provide some help? I am currently using the jquery.slidereveal.js plugin from ''. The plugin works well when manually clicking the trigger to open and close the menu. However, I would like it to default to its last state on page load, ...

JavaScript Tutorial: Storing HTML Text in the HTML5 Local Storage

I am looking to save the text that is appended using html() every time I click on a button. The goal is to store this text in HTML 5 local storage. $('#add_new_criteria').on('click',function(){ $('#cyc_append').html(&apo ...

Reveal the CSRF token to the client located on a separate domain

Utilizing the module https://www.npmjs.com/package/csurf to safeguard my public routes from cross-site request forgery. Due to the server and client being on separate domains, a direct method of passing the generated token to the client is not feasible. I ...

Modifying the label focus does not alter the CSS style

I'm struggling with a simple form where I want to highlight the focused labels by changing their background colors. However, the jquery code doesn't seem to be working as expected. Despite no errors showing up in the console, the functionality is ...