Angular 2 is showing an error message: TS1005 - It is expecting a comma

Upon compiling, I encountered the following error:

I am unable to locate where a comma needs to be inserted.

src/app/navbar.component.ts(29,39): error TS1005: ',' expected.
src/app/tache.service.ts(53,53): error TS1005: ',' expected.

Error in navbar.component.ts

      add(name: string): void {
        name = name.trim();
        if (!name) { return; }
        this.tacheService.create(name)
        .then(tache => {
             this.tacheService.insert( tache: Tache); // found at line 29
        });
      } 

Error in service.ts

update(tache: Tache): Promise<Tache> {
        tache.stat = 1;
        return this.http
          .put(this.tachesUrl, JSON.stringify(tache.stat:1), {headers: this.headers}) // found at line 53
          .toPromise()
          .then(() => tache)
          .catch(this.handleError);
      }

Answer №1

I believe passing the data type as an argument is not necessary:

this.taskService.addTask(task: Task);

Instead, it should be written as:

this.taskService.addTask(task);

Answer №2

When calling this.tacheService.insert( tache: Tache); on line 29, the first error occurred.
By simply calling this.tacheService.insert( tache); instead, there was no Error encountered.


On line 53, when attempting to put data to this.tachesUrl with JSON.stringify(tache.stat:1), a second error was triggered.
However, by using JSON.stringify(tache.stat) without any issues, No Error was reported.


Similarly, putting data to this.tachesUrl with JSON.stringify(tache.stat) and utilizing this.headers did not lead to any errors.
The operation proceeded without encountering any issues thanks to these adjustments.

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

Parsing a JSON object in JavaScript: A step-by-step guide

Looking for assistance on how to parse the JSON object below: { "info": [ { "systemIp": "192.168.1.1", "status": "done 956" }, { "systemIp": "192.153.1.1", "status": "done" } ] } Does anyone have a solution using Javascript or jQuery? The desired output ...

Navigating Angular: Uncover the Secrets of Unwrapping Json Data

I need some help with parsing Json data in Angular TypeScript. The data is structured as follows: https://i.sstatic.net/H7s8q.png When calling a REST API, I want to convert a Java class object into an array of model classes. How can this be achieved? "g ...

The RSS feed reader is currently malfunctioning

I'm having trouble loading an RSS feed from the following URL: http://solutions.astrology.com/scripts/it.dll?cust_id=aamfha&doc=daily07short/dailyshort.xml Here is the code I am using to try to read it: url = 'http://solutions.astrology.co ...

Encountering a problem with Tailwind dynamic grid in Vue3

Greetings fellow Stack Overflow members! I am currently working on a project using Vue3 + tailwindcss. My goal is to create a dynamic grid layout similar to the following: Corrrection: Here, I am aiming for a repetitive layout with dynamic loop items ...

Add an element to an array using the `push` method in JavaScript

I am currently studying the code for creating a canvas circle motion trail effect. I am a bit puzzled by the push(x:Pos,y:Pos) within thestoreLastPosition() function in the sample code provided below: ctx = canvas.getContext('2d'); var xPos = - ...

Tips on combining multiple HTML tags within a single div element

After extracting a value from an XML document using Javascript, I encountered a problem while attempting to generate multiple image tags based on that value. Despite my attempt with a for loop, only one image was being displayed. for(i=0; i<red; i++){ ...

Store image selection in state

I am currently working on building an imagePicker in ReactNative, but I am running into an issue when trying to select the image. The error message I am receiving is: TypeError: this.setState is not a function. (In 'this.setState ({ avatar: data}) &a ...

What is the best way to save information from an ng-repeat loop into a variable before sending it to an API?

My goal is to store the selected value from ng-repeat in UI (user selection from dropdown) and assign it to a variable. function saveSelection() { console.log('inside function') var postToDatabase = []; vm.newApplicant.values ...

Access an object within the ngOnInit lifecycle hook

Is there a way to access an object from the ngOnInit function and use it outside the class in the same component? Let me explain: I am implementing an Angular Material table and want to dynamically populate it with data retrieved from Firebase. ngOnIn ...

Display all dates within a specific range using the indexOf method

I am working on creating a datepicker in vue3. As part of this, I want the days between two selected dates to be highlighted when hovered over. I have attempted to achieve this using the "indexOf" method, but unfortunately, I am not getting the desired res ...

Making HTTP requests with axios in Node.js based on multiple conditions

I'm facing an issue with making get calls using axios to both activeURl and inactiveURl. The goal is to handle error messages from the activeUrl call by checking data from the inactiveUrl. However, I keep receiving error messages for the inactiveURL e ...

The NX Monorepo housing a variety of applications with unique design themes all utilizing a single, comprehensive UI component

We are currently working on a design system for a NX monorepo that has the potential to host multiple apps (built using Next.js), all of which will share a common component library. While each app requires its own unique theme, the UI components in the lib ...

Utilizing JSON parsing for JSON-LD in JavaScript

Tried parsing a JSON data obtained from json-ld Here's the JSON snippet for reference: { "@context": "http://json-ld.org/contexts/person.jsonld", "@id": "http://dbpedia.org/resource/John_Lennon", "name": "John Lennon", "born": "1940-10-09", ...

The correct method for concealing components from unauthorized users in Vue

After much thought, I'm considering transitioning my app entirely to Vue frontend. However, there are some concerns on my mind, such as: Currently, in Laravel blade (posts page), I have the following structure: @foreach($posts as $post) <post dat ...

How to retrieve the value of a nested checkbox in Angular using dynamic methods

I successfully developed dynamic nested checkboxes in Angular and now I am looking to retrieve the values of the selected checkboxes. However, I encountered an issue with the JSON structure needed to implement this functionality. https://i.stack.imgur.com ...

Tips for verifying the presence of a specific value within an array of union types

Given an array of a specific union type, I am trying to determine if a string from a larger set that includes the union type is present in the array during runtime: const validOptions: ("foo" | "bar")[] = ["foo", "bar"] type IArrType = typeof validOptions ...

Is there an autocomplete equivalent in Angularfire5 and Firebase that functions similar to WHERE LIKE?

Here is how my autocomplete services for Firebase using AngularFire2 v5 are structured: getUsersTypeAhead(searchString: string) { const list: AngularFireList<User> = this.fireBase.list('/users', ref => ref .orderByChild(&apo ...

Is there a way to make my red div switch its background color from red to green when I press the swap button?

How can I make the red div change its background color to toggle between red and green when I click on the swap button in the following code? $(document).ready(onReady); var numberOfClicks = 0; function onReady() { console.log('inside on ready ...

Using NextJs to create a permanent redirect from the www version of a site to the non

I have developed a website using Nextjs (version 12.1.4). To enhance the SEO of my site, I want to create a permanent redirect from the www version to the non-www version. Typically, this can be achieved easily using nginx or an .htaccess file with apache. ...

Large header picture

Instead of tiptoeing around the issue, let me just be blunt and ask: I'm curious about how they created this image header. Even after removing all javascript code and css using Chrome's property inspector, the image continued to stretch. The sty ...