The reset function is malfunctioning on the meteor entity

Currently, I am going through an angular-meteor tutorial that can be found here

I seem to be facing some issues with my code. Here's what I have:

angular.module('socially').controller('PartyDetailsCtrl', function($scope, $stateParams, $meteor){
    $scope.party = $meteor.object(Parties, $stateParams.partyId, false);

    $scope.save = function() {
    $scope.party.save().then(function(numberOfDocs){
      console.log('save success doc affected ', numberOfDocs);
    }, function(error){
      console.log('save error', error);
    });
  };

  $scope.reset = function() {
    $scope.party.reset();
  };
});

Below is the HTML code:

You will find party details displayed here:

<input type="text" ng-model="party.name">
<input type="text" ng-model="party.description">

<button ng-click="save()">Save</button>
<button ng-click="reset()">Reset form</button>
<button ui-sref="parties">Cancel</button>

The save button works fine and saves the object without any issues. However, when I try to reset the form using the reset button, it doesn't seem to do anything – no errors are shown either.

Answer №1

When you use $scope.party.reset();, the form does not get cleared. Instead, the current value of the object is reset to what is stored in the database. For example, if you make changes to a Parties document and then call the reset function, the version of the Meteor object on the client side will revert back to the server's version.

To learn more, check out $meteor.object.

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

Unable to modify the default Nuxt favicon

Just getting started with Nuxt and attempting to update the default favicon for my project. I swapped out the favicon.png and favicon.ico files in my static directory, but unfortunately, it didn't take effect. Next, I tried replacing the favicon.png ...

Using AngularJS to implement validation on radio buttons

My application is a cross-platform app that utilizes AngularJS, Monaca, and Onsen UI. Within one of the views, there exists an array of list items where each item can be associated with a random number of radio buttons. These lists are dynamically generat ...

Error Encountered: Eclipse Luna Crashing due to Null Pointer

Every time I click on a project, JSP page, or Java file in my Eclipse Luna, it keeps throwing a 'Null Pointer Exception'. This problem started happening after I attempted to install an AngularJS plugin. I am confused and not sure what the issue i ...

What is the best way to update a canvas chart when the side menu is hidden?

I am facing an issue with the layout of my webpage, which includes a left side menu and a canvas chart. The left side menu occupies the first 155 pixels of the width, leaving the rest for the canvas chart set to a width of 100%. However, when I close the ...

Adjust CSS classes as user scrolls using skrollr

I am currently facing an issue with the prinzhorn/skrollr plugin when trying to use removeClass/addClass on scroll function. I have attempted to find a solution but unfortunately, nothing has worked for me. <li class="tab col s3"><a data-800="@cl ...

One array comprises of all elements found in a separate array

After grappling with this problem for a while, I still haven't been able to find a solution. If I have 2 arrays structured like this: array1 = [ { name: 'John', age : 25}, { name: 'Jane', age : 58} ] array2 = [ { name: ...

Is it possible for setting the height of a div container to disable clicks within the div

There is a peculiar issue I am facing. I have an input button within 3 nested divs, with the outermost one having the id "container". Strangely, when I specify the height of "container", the click events for inputs with ids "switch" and "next" do not work ...

Is there a way for me to create a clickable link from a specific search result retrieved from a MySQL database using an AJAX

Currently, I am attempting to create an ajax dropdown search form that provides suggestions based on results from a MySQL database. The goal is for the user to be able to click on a suggestion and be redirected to the specific product. The code I am using ...

Encountering a "Index of /" error when working on a basic HTML project with Tailwind

I am having trouble understanding how to properly set up and manage version control for my projects. I initially created a project using Tailwind CSS that worked fine on my local machine with an http-server plugin. However, when I tried to create a GitLab ...

Displaying JavaScript - Nothing to Echo in PHP

Using PHP to echo a JavaScript block, I have encountered an error message. echo "<script language='javascript' type='text/javascript'> jQuery(document).ready(function($){ var $lg = $('#mydiv'); ...

Inject a snippet of temporary code at the end of the CSS file using JavaScript or JQuery

I am looking to dynamically add temporary CSS code to the end of an external CSS file or modify it using JavaScript or jQuery. For example, let's say my mystyle.css file looks like this: //mystyle.css p{color:red} Now, when a user interacts with the ...

In the realm of Express JS, there are two applications communicating with each other for

I'm having trouble with the code below - it's not returning a response. Can anyone suggest what might be causing this issue? var express = require('express'), app1 = express(), app2 = express(); app1.use(function(req, res, ne ...

Error message in nodejs: Content-type specified is invalid (status code: 415)

I am seeking guidance on how to send form data with headers using the request module. Within my code, I have a function called getToken that makes a POST request with headers and form data. The response data from this request is then used to make another ...

Acquire the current audio video stream directly from the web browser

Currently, I am utilizing a JavaScript library that internally invokes getUserMedia. My objective is to access the stream object that has already been initiated. Unfortunately, the library does not provide any means to retrieve it. Is there a method avai ...

AngularJS does not clear the array after a POST request is made

ISSUE Greetings! I am encountering an odd behavior with my backend. When I submit data, everything works flawlessly. However, if I press ENTER and submit an empty field, it reposts the previous value. Initially, I cannot submit an empty field, but after e ...

What is the best way to implement a scroll-into-view feature for a newly added list item in Vue.js?

I am currently utilizing vueJS to create a task viewing application. My goal is to make the div containing the list focus on the newly added list item immediately after adding a new task. Here's the HTML code from my template for the task list: < ...

What could be causing the QullJS delta to display in a nonsensical sequence?

The outcome showcased in the delta appears as: {"ops":[{"retain":710},{"insert":" yesterday, and she says—”\n“The clinic?","attributes":{"prediction":"prediction"}},{"del ...

Utilizing Javascript to interact with GroupMe API through POST method

I've been working on creating a client for GroupMe using their provided API, but I'm stuck and can't seem to figure out what's going wrong. curl -X POST -H "Content-Type: application/json" -d '{"message": { "text": "Nitin is holdi ...

When using JavaScript, the results of stringifying an array may not always align with

Can someone please assist with a strange issue I am experiencing in JavaScript? After clicking on the 'test' link, an alert pops up displaying: "[]" I was actually expecting to see something like: "[{'temp':25},{'thermState' ...

Error message "Sphere undefined" encountered in ThreeJS Water2 example

I've been experimenting with setting up the basic ThreeJS Water2 example that can be found here: You can access the source code here: https://github.com/mrdoob/three.js/blob/master/examples/webgl_water.html The process appears simple at first glance ...