Setting the date in a datetimepicker using the model

I've encountered an issue while trying to utilize the angular date time picker. It seems that when I load data from the model, the picker does not bind the value correctly.

If I manually set the value to a date, it works fine. However, when the data is loaded from the model, the picker fails to display the correct value.

http://plnkr.co/edit/eeTQFo5jz4RYN6nSYxdZ?p=preview

I have incorporated the datetimepicker for use with angular.

angular:

var app = angular.module('plunker', []);

app.controller('MainCtrl', function($scope) {
  $scope.date = '01/02/1983 01:02:03';
});


app.directive('datetimez', function() {
    return {
        restrict: 'A',
        require : 'ngModel',
        link: function(scope, element, attrs, ngModelCtrl) {
          element.datetimepicker({
            dateFormat:'dd/MM/yyyy',
            timeFormat: 'hh:mm:ss',
          }).on('changeDate', function(e) {
            ngModelCtrl.$setViewValue(e.date);
            scope.$apply();
          });
        }
    };
});

HTML:

<div class="container container-fluid" ng-controller="MainCtrl">
  2+2={{2+2}}, var1={{var1}}
  <form class="form-horizontal" novalidate name="form" ng-submit="submit()">
  <div class="well">
    <div id="date" class="input-append" datetimez ng-model="var1">
      <input data-format="dd/MM/yyyy hh:mm:ss" type="text" ng-value="date"></input>
      <span class="add-on">
        <i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
      </span>
    </div>
  </div>

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

The customized message for parsley's minimum length is not being applied properly when passed as an option during binding

When attempting to bind the Parsley script to an input field, I am encountering an issue with the minlength message not displaying my custom one. Instead, the default error message from Parsley is being shown. I've tried adjusting the code but it does ...

What's the scoop with for loops and grabbing elements?

In my code, I have a for loop that looks like this: for(i=0; i<6; i++) { if(i = 0) {a1 = '<div>something1</div>';} if(i >= 1 & i <= 5) {b1 = '<div>something2</div>';} } document.getElementById(&apos ...

Different results can be observed when comparing the array ordering in JavaScript between IE8 and Chrome

The array presented with items listed in specific order: { "5":{ "Title":"Title A", "Desc":"Description A" }, "15":{ "Title":"Title B", "Desc":"Description B" }, "10":{ "Title":"Title C", "Desc":"Description C ...

Is it possible to incorporate a timer script like chrontab within an Apache setting?

Is it possible to create a chronTab that runs a php script on an Apache web server (Unix based systems) in conjunction with the Node.js server-side program? My goal is to use this to check if a browser is still active and when to end sessions. The chronTa ...

When a React page is re-rendered using useEffect, it automatically scrolls back to the

Every time I utilize the <Tabs> component, the onChange method triggers the handleTabChange function. This leads to the component being called again and after repainting, the useEffect is triggered causing the page to scroll back to the top. How can ...

`Optimizing Performance using jQuery Functions and AJAX`

As someone exploring ajax for the first time, I'm eager to learn how to write jQuery code that ensures my simple functions like slideshows and overlays still work smoothly when a page is loaded via ajax. Currently, I am implementing the following met ...

Waiting for an API call to complete before loading a specific path in REACT - how can this be achieved?

When using the axios post to request access to the application from the backend, the issue arises when axios returns undefined and then true or false. This leads to a problem in managing the private Route based on these responses. The question is, is axi ...

Navigating through each element of an array individually by using the onClick function in React

I'm currently working on a project that involves creating a button to cycle through different themes when pressed. The goal is for the button to display each theme in sequence and loop back to the beginning after reaching the last one. I've imple ...

Encountering the error message "React child cannot be an object" while trying to map over an imported object referencing components

I have an array in a separate file that I import and iterate over in another component. One of the properties within this array, labeled component, actually refers to a different individual component. I am attempting to render this component, but I keep e ...

Creating a user-friendly error message on the interface using JavaScript

I have implemented a table that showcases data from the Geonames API. Currently, I am working on creating a function to handle errors when the user forgets to fill in the input fields and then trigger an alert on the interface. The code snippet below sho ...

Sharing variables between different routes in ExpressJS

Currently, I am utilizing ExpressJs with Node.js and have organized all my routes in a 'routes' folder. When setting up the server, my process involves establishing a DB connection followed by defining the routes as shown below: var routes = re ...

Utilize Lodash to iterate through functions in a loop and retrieve the first matching result

I am looking to iterate through an array of objects and call a method on them. If the result of that method meets certain conditions, I want to immediately return that result. The current implementation is as follows: public getFirstMatch(value: string, a ...

Preventing Text Truncation in THREE.js Texture Created from 2D Canvas

Many people tend to use the 2D canvas texture method for creating text billboards, sprites, and overlays in THREE.js scenes instead of relying on imported image files. You can check out an example by Lee Stemkoski here. However, I have noticed that when a ...

Determine the text's length inside a div element by utilizing the div itself

I have a div with a fixed width of 30% and I am trying to find the length of the text within that div. Check out my JSFiddle for the code. The current code snippet I am using is: var text=$('#test').text(); text=text.trim(); var len=text.lengt ...

Building a versatile dropdown menu with ReactJS and creating reusable components

I am currently working on building a dropdown menu following a tutorial, but I have encountered a roadblock. Instead of using the "props" keyword as shown by the instructor in the tutorial, I passed the props directly as arguments without using props dot. ...

Click on a link element within a container and create a pop-up window using jQuery

I'm having trouble creating a popup using jQuery for the second A tag within a div. Here's what I've attempted: $(function() { $(".sites").find("a").eq(1).css("color", "red").dialog({ autoOpen: false, show: { effect: "fade ...

What is the best way to identify when the soft-keyboard is hidden in the Android browser

Having trouble with the Android Webkit browser and need to manually detect when the soft-keyboard is hidden by pressing the button in the top right corner. https://i.stack.imgur.com/x11Vp.jpg In the image above, pressing the button hides the soft keyboar ...

AngularJS is throwing an error when trying to use a specific module

Hello everyone, I am a beginner with angular.js and I am encountering a problem that I need help with. I have tried to create a basic screen using a controller and a module in my example, but unfortunately, it is not working as expected. Below is the examp ...

Eliminate forward slashes in MySQL queries within a Node.js environment

Here is the code snippet that I am working with. pool.getConnection(function (err, connection) { connection.query("delete from userFiles where type = 1 and typeId = " + taskId + " and fileName ...

Mastering the art of raycasting onto a point cloud in ThreeJs R71

I am currently working with Autodesk Forge, leveraging Three.js r71, and I am looking to implement a raycaster to identify clicks on various elements within a point cloud. If anyone could provide a sample code snippet on how to achieve this using Three.js ...