An issue with the AngularJS [$parse:syntax] error has been identified when using specific data in the

I encountered an issue when attempting to create an AngularJS ui-grid table with data that includes a '(' and then whitespace before the closing ')' within a string. This resulted in an AngularJS error message:

Syntax Error: Token '32' is unexpected, expecting [)] at column 22 of the expression [entity[''](trimpoint 32h)] starting at [32h].

Below is the HTML code I used in an attempt to build the table:

<html> <head>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-grid/3.2.5/ui-grid.css" /> 
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.21/angular.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-grid/3.2.5/ui-grid.min.js"></script>
    <script type="text/javascript">

var app = angular.module('MyGridApp', ['ui.grid']);

app.controller('bodyController', ['$scope', function($scope) {
    $scope.myData = [{'(trimpoint 32h)': "Moroni", age: 50},
                     {'(trimpoint 32h)': "Tiancum", age: 43},
                     {'(trimpoint 32h)': "Jacob", age: 27}];
    $scope.gridOptions = { data : 'myData' }; }]);

    </script> </head> <body ng-app="MyGridApp" ng-controller="bodyController">
    <div ui-grid="gridOptions">
    </div> </body> </html>

By replacing the round brackets with square brackets, the table renders without any issues. Here's how the data looks after the modification:

$scope.myData = [{'[trimpoint 32h]': "Moroni", age: 50},
                 {'[trimpoint 32h]': "Tiancum", age: 43},
                 {'[trimpoint 32h]': "Jacob", age: 27}];

I am curious about why AngularJS throws an error while trying to interpret this data. It appears to be a valid JavaScript string for use as an object name. Any insights would be appreciated. Thank you.

Answer №1

To solve the issue, it is necessary to add a non-blank space before each parenthesis.

You have a few options for this: place { } or utilize a unicode character like Alt + 255 on Windows. Alternatively, you can type Ctrl + Shift + U, hold down Ctrl + Shift, and input 00A0 on Linux. Opening the characters map might also be useful in this situation.

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

Encountered a network error: A rogue token < was found in JSON at position 0 within a new Apollo

https://i.sstatic.net/D25ai.png const httpLink = createHttpLink({ uri: 'http://localhost:3090/' }) const client = new ApolloClient({ link: httpLink, cache: new InMemoryCache() }) client.query({ query: gql` query users { ...

Clear existing markers from the map before inserting new markers

I have a map where initially the markers load coming from the database, Then there is a time-based Ajax request that fetches new records every minute. In my code snippet, I am using setMapOnAll(null) following the guidance from the Google Maps Documentati ...

Strange behavior observed when transitioning from a standard string to an LPCSTR

While experimenting with strings, I encountered an unusual behavior when converting a std::string to a LPCSTR. To illustrate the issue, I created a small test application: #include <string> #include <Windows.h> #include <iostream> usin ...

How can I alter the columnWidth setting in Masonry when detecting a different screen width or window width?

I am currently working on adjusting the layout of my masonry script to respond accordingly when the browser window or screen width drops below a certain threshold. However, I am running into issues as it seems to break whenever I try to make this adjustmen ...

Create a fresh trail underneath the overlay image

When utilizing fabric.js to draw a new path with isDrawingMode: true enabled (seen on the right side of the screenshot), I am encountering an issue where the path appears above my overlay image, which is a transparent png. https://i.stack.imgur.com/R3fGn. ...

When using Vuejs + Laravel to make an Ajax request, only the most recent information entered into the view is submitted

Can someone guide me on implementing a basic ajax request using Vue with my Laravel backend? I have a boolean field called completed in a table named courses. In the view, users can see all assigned courses and toggle their completion status by pressing a ...

Error in SO Embed Snippet Fiddle due to Bootstrap 4 JS Issue

Just wondering, any idea why the bootstrap 4 js is throwing this error: https://i.sstatic.net/J4Iq4.png when trying to embed the snippet? (No errors in the external Fiddle) Added tether.js but no luck (kept it commented). Switched to jQuery 2.2.1 on th ...

Quasar unable to detect vuex store

I am currently working with the Quasar framework and I am trying to add a store module. Despite running the quasar new store <name> command, I keep receiving the message "No vuex store detected" in the browser console. Any idea where the issue migh ...

Alter the navigation background when moving between sections on a one-page website

I need to ensure that the background of the navigation remains transparent on the "home" section. However, when switching to other sections, the background color of the navigation becomes permanently black. <header class="clearfix"> <nav> ...

Determine which JavaScript script to include based on whether the code is being executed within a Chrome extension

I am in the process of developing a Chrome extension as well as a web JavaScript application. I currently have an HTML container. I need the container.html file to include <script src="extension.js"> when it is running in the Chrome extension, and ...

The useEffect function is executing two times

Check out this code snippet: import { type AppType } from 'next/app' import { api } from '~/utils/api' import '~/styles/globals.css' import Nav from '~/components/Nav' import { useEffect, useState } from 'react& ...

I am experiencing an issue with my d3 force directed graph where the links are not

I am relatively new to d3 and have limited experience with web frontend development. In my current web application project, I am attempting to create a force directed graph. Despite spending several hours trying to make it work, I have been unable to displ ...

Sending data to server using Ajax and jQuery

Hey there, experiencing a little hiccup in the back-end of my system when I try to submit my form. It keeps showing me an error saying Unidentified index: file1 . Can't seem to pinpoint where the issue lies in my code. Even though I'm no beginner ...

What could be the reason for the unexpected outcome when checking if display is equal to "none"?

I have a JavaScript function called "display()". I want to hide my navigation menu on click, but it is not working properly - it just blinks. I am looking for a solution that uses only JavaScript and does not involve querySelector. function display() { ...

Is it possible to refresh the browser with a specific URL using Node or Gulp?

Excuse me if this is not the appropriate place to pose my query. Unfortunately, due to the limitations of my workplace/CMS setup, I am unable to access a local version of the website for development purposes. Instead, we are working on CSS and JS locally ...

Creating an engaging maze game using Java programming

Currently, I am working on a Java program for a maze game. The game reads in a text file called "map" to determine the layout of the maze. Players have to navigate through the 2D array maze using user input while avoiding cave-ins (represented by Xs) and r ...

Sorry, but React does not accept objects as valid children. Make sure the content you are passing is a valid React child element

I encountered an issue with rendering on a screen that involves receiving an object. The error message I received is as follows: Error: Objects are not valid as a React child (found: object with keys {_U, _V, _W, _X}). If you meant to render a collection o ...

Using jQuery to add emoticons to a div element

I am currently developing a small chat application and I would like to incorporate emojis into it. My goal is to allow users to click on an emoji, which will then appear in the text area where they type their message. When a user clicks on "select," I want ...

Verifying dynamic number inputs generated using JavaScript values and calculating the total with a MutationObserver

Preamble: I've referenced Diego's answer on dynamic field JS creation and Anthony Awuley's answer on MutationObserver for the created fields. After extensive searching, I found a solution that meets my needs, but it feels somewhat bulky des ...

Utilizing hover effects and timeouts to conditionally show React components

I encountered a challenging React layout dilemma. It's not a complex issue, but rather difficult to articulate, so I made an effort to be as clear as possible. The data I have maps individual components in the following way: map => <TableRow na ...