in Education by
i have an Angular Factory that gets a single date from the backend of my spring application, and i wanted to add it to an Input so the calendar input is always set with the date obtained from the backend, without the possibility for the user to change it. How could i achieve this? Should i put it on my controller or directly on the button? This is my code: Factory(concatenated with other .factory): .factory('DataInizioGeneraCalendario', function ($resource) { return $resource('rest/anagrafica/dataInizioGeneraCalendario', { get: { method: 'GET' } }); Controller Function: $scope.generaCalendario = function () { $scope.modificaCalendarioDiv = true; $scope.successMessage = false; $("#idModificaCalendarioDiv").hide(); $scope.element = new Calendario(); autoScroll('generaCalendario'); $("#idErrorTemplate").hide(); $('#data').attr('disabled', false); $("#idGeneraCalendarioDiv").show(); }; Input :
Edit : forgot to add, the controller function is called by the button that displays the input for the calendar. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Because your factory's GET request will return the date value asynchronously, it's better to have a $scope.date in your controller that will hold the date value that is returned from the server. Also, depending on the format in which you store dates on the backend, you might need to transform the value that is returned from the backend into the string format, so it would be properly consumed by the as per Angular docs. In your code, you need to bind the input element to this value, like this: . What it will do is bind this input to the data model, so that every time when user edits the input the $scope.date would be updated too. If you do not want users to be able to edit this date, then you need to: Keep the input field disabled (no need to use ng-disabled here, because you want to keep it always disabled). And also remove this line: $('#data').attr('disabled', false); in your function. You the one-way binding, instead of two0way binding, like this: Here is the working DEMO that shows two inputs: one that is editable and another that is not.

Related questions

0 votes
    I've a lookup activity with gets value from a container within a blob. I have a foreach activity which is ... : data.speed> 500 Select the correct answer from above options...
asked Feb 4, 2022 in Education by JackTerrance
0 votes
    I'm currently running an ec2 micro instance and i've been finding that the instance occasionally runs out of memory. ... can be done? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    So I am having trouble with setting the state for the date selected from this DatePicker change: change = ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    So I am having trouble with setting the state for the date selected from this DatePicker change: change = ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 22, 2022 in Education by JackTerrance
0 votes
    How QA can add a value to an agile team?...
asked Nov 26, 2020 in Technology by Editorial Staff
0 votes
    What will do you with a missing value in an observation? Options 1 from the point of definition onward in the ... the function. Tin Select the correct answer from above options...
asked Nov 28, 2021 in Education by JackTerrance
0 votes
    I mean this Datepicker: https://uxsolutions.github.io/bootstrap-datepicker/ HTML: Fecha de inicio Fecha de ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 10, 2022 in Education by JackTerrance
0 votes
    Using classic templates, publishing via FTP to a custom domain. I want to add custom elements such as: ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    How do you add a particular state to the browsing history? (a) pushState() (b) replaceState() (c ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    Do you know how you could add support for Web Service transactions?...
asked Jun 6, 2021 in Technology by JackTerrance
0 votes
    How can a column with a default value be added to an existing table in SQL Server 2000 / SQL Server 2005? Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    I'm developing a website using WordPress as my Framework. The templates are highly customized and really ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 26, 2022 in Education by JackTerrance
0 votes
    I am trying to display a DatePicker dialog on top of another activity and what is happening is it is ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    With a chrome plugin, I changed my timezone to +14. However, I saw that the calendar app is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    When creating a jQuery UI datepicker on a detached div it works fine in Firefox but in Chrome it gets ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
...