What could be causing my AngularJS directive to malfunction in Edge browser?

I have encountered an issue where this code works fine in all major browsers, but Edge only shows the valid value in the DOM inspector. The page still displays the old value. Why is this happening?

(function (angular, module) {

  'use strict';

  module
    .directive('psEffectsDurationSlider', EffectsDurationSlider);

  EffectsDurationSlider.$inject = [];

  function EffectsDurationSlider() {
    return {
      require:  'ngModel',
      restrict: 'E',
      link:     link
    };

    function link(scope, element, attrs, ngModel) {
      ngModel.$render = render;

      activate();

      function initializeSlider() {
        element.slider({
          min:         0.2,
          max:         2,
          step:        0.1,
          animate:     true,
          orientation: 'horizontal',
          range:       'min',
          slide:       onSliderChange
        });
      }

      function render() {
        element.slider('value', ngModel.$viewValue);
      }

      function onSliderChange(event, ui) {
        ngModel.$setViewValue(ui.value);
      }

      function onScopeDestroy() {
        element.slider('destroy');
      }

      function activate() {
        initializeSlider();

        scope.$on('$destroy', onScopeDestroy);
      }
    }
  }

})(window.angular, window.angular.module('...'));

Screenshot from Edge with valid value in the DOM inspector and invalid result at the page: https://i.stack.imgur.com/QP49c.png

Answer №1

To ensure the model update is properly synchronized with the slider event, consider using $timeout within the function.


function handleSliderEvent(event, ui) {
    $timeout(function(){
        ngModel.$setViewValue(ui.value);
    });
}

Additionally, remember to include the $timeout injection in your code.

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

Refresh KendoUI Grid data with latest additions

I currently possess: $.post('buying-grid/split/' + config.route.params.id, item).success(function(data){ var ds = new kendo.data.DataSource(); ds.data(data) $('#buyingGrid').data('ke ...

Currency symbol display option "narrowSymbol" is not compatible with Next.Js 9.4.4 when using Intl.NumberFormat

I am currently utilizing Next.JS version 9.4.4 When attempting to implement the following code: new Intl.NumberFormat('en-GB', { style: 'currency', currency: currency, useGrouping: true, currencyDisplay: 'narrowSymbol'}); I ...

The app.get() function seems to be inactive and not triggering in the Express application

I am currently exploring the MEAN stack and experimenting with implementing express. I've encountered a peculiar issue where I keep receiving a 404 error when trying to access a specific path that I have configured for the app object to manage. Oddly ...

Obtaining a byte array using the file input method

var profileImage = fileInputInByteArray; $.ajax({ url: 'abc.com/', type: 'POST', dataType: 'json', data: { // Other data ProfileImage: profileimage // Other data }, success: { } }) // Code in Web ...

AngularJS is throwing an error because it can't find a function called 'undefined' in Controller xxx

Just diving into the world of Angular. I'm following an example from a reputable book, but encountering an issue with the Cart Controller not being recognized as a function. Here's the code snippet causing trouble: HTML: <!DOCTYPE html> & ...

Notifications for AngularJS tabs

I need help finding a method to incorporate "tab notification" using AngularJS, in order to show that there are important alerts that require attention. For example: (1) (3) TAB_ONE TAB_TWO TAB_THREE Could you provide any recom ...

The requested API endpoint for retrieving the name could not be found on the Express

Struggling to configure the restful API for my express app. Below is my app.js code: var express = require('express'), app = express(), bodyParser = require('body-parser'), methodOverride = require('method-override'); rout ...

Troubleshooting Jasmine Unit Testing issues with the ng-select library

Recently, I integrated the ng-select component from Github into my Angular application without encountering any console errors during runtime. It functions as expected; however, issues arise when running unit tests with Jasmine. To incorporate NgSelectMod ...

Axios failing to include Content-Type in header

I have set up an Odoo instance in the backend and developed a custom module that includes a web controller. Here is the code for the web controller: Web Controller # -*- coding: utf-8 -*- from odoo import http import odoo from odoo.http import Response, ...

Efficiently Implementing ngIf Post-Transclusion

I am working on a list component where I need to define custom columns within it. These columns are then transcluded into the row of the template for the component. However, I have run into an issue where I am unable to use ngIf in this specific context. ...

Update the styling for the second list item within a specified unordered list class instantaneously

Looking to emphasize the second list item (li) within a selected dropdown list with a designated unordered list class of "chosen-results". <div class="chosen-container chosen-container-single select-or-other-select form-select required chosen-proc ...

Tips for avoiding event listeners from being triggered multiple times

Implemented an event listener on an HTML element that was retrieved by className within the render method of highcharts, but for some reason, the listener is being triggered twice. The issue seems to be with the onClick handler in the highchart's rend ...

The component "react-native-snap-carousel" is having trouble displaying the card image

Recently, I started working with react native and encountered an issue while trying to implement the "react-native-snap-carousel". The carousel was functioning correctly with the data provided in the "carouselItems" array, but I faced difficulties with dis ...

Using Node to upload various large JSON files into mongoDB

Currently, I am dealing with the task of parsing numerous large JSON files into my mongoDB database. To accomplish this, I have been utilizing the stream-json npm package. The process involves loading one file at a time, then manually changing the filename ...

sent a data entry through ajax and performed validation using jquery

Is there a solution to validating the existence of an email value using ajax after validation work is completed? Despite attempting to check for the email value and display an alert if it exists, the form continues to submit regardless. See below for the ...

Issue with scroll down button functionality not functioning as expected

Is there a way to create a simple scroll down button that smoothly takes you to a specific section on the page? I've tried numerous buttons, jQuery, and JavaScript methods, but for some reason, it's not working as expected. The link is set up co ...

Conditions in Controller Made Easy with AngularJS

I have recently started working on implementing a notifications feature. The service will involve making a GET request to a specific URL which will then return an array of notifications. Within the controller, I am in the process of setting up a variable ...

Building a dynamic web application using AngularJS and Spring MVC for seamless data redirection

I am still learning AngularJS and this question might sound a bit peculiar. My current challenge involves redirecting to a new page with data-binding from a Spring Controller. The scenario is that upon clicking a button or hyperlink on one page (let&apos ...

Integrate an item into the request body utilizing the $.load() function in jQuery

Currently, I am using a POST request via jQuery's $.load function to retrieve data to display in a window. This is what I am currently doing: var testObject = { thing1: 'data1', thing2: 'data2', thing3: &a ...

When attempting to execute a function within another function in JavaScript, a ReferenceError is triggered

I recently developed a straightforward app that utilizes the Google Drawing Library (https://developers.google.com/maps/documentation/javascript/examples/drawing-tools) to allow users to draw circles on a map. The first circle represents the source locatio ...