The Angular controller encountered an unexpected token

I have organized all my Angular controllers in one controller file.

However, I encountered an issue when trying to print out a specific part of my object array at the end of a controller. Everything worked fine until I added a new controller after the current one - then none of my views were rendered and I received the following error message.

Uncaught SyntaxError: Unexpected token >

The error points to this section of code:

 $scope.formats = [];

    $scope.productTypeChange = function () {
        $scope.formats = $scope.productsandformats.find(ps => ps.name == $scope.formData.Product.name
    )
    }

I have searched on Stack Overflow and Google for a solution but haven't found one yet. Any easy fixes you can suggest? Thank you!

Answer №1

The issue at hand is the error message Uncaught SyntaxError: Unexpected token >. This occurs due to an unexpected space between the arrow operator.

$scope.formats = [];

$scope.productTypeChange = function () {
    $scope.formats = $scope.productsandformats.find(ps => ps.name == $scope.formData.Product.name
)

For more information on Arrow functions, refer to the documentation provided by Mozilla.

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

Is it possible to convert an object with properties of equal length into a list of objects using JavaScript?

I am working with an object that has multiple keys, each containing a list of equal length: myobj = { 'key1' : [1, 2, 3], 'key2' : ['a', 'b', 'c'], 'key3' : [true, false, true], .. ...

Is the for loop programmed to stop at the first match?

I've been working on filtering a txt file using nodejs. Here's my code snippet: const fs = require('fs') let list = fs.readFileSync('./newmR.txt', 'utf-8').split('\r\n') console.log(list.length) ...

Attempting to insert an empty <option> into a dropdown menu using jQuery and ajax functionality

I'm working on a JavaScript function that dynamically populates a select dropdown based on the value of another select dropdown. I want to include an empty option at the beginning. Here is the code snippet for the function: function createParkFloorM ...

Manipulating the Document Object Model (DOM) without using Angular

I am facing an issue with an AngularJS modal working alongside a BackboneJS-built app. The header of the page is created by the Backbone code, and within this header, there is a button that triggers the opening of the Angular modal. The problem arises bec ...

Retrieve the parseJSON method using a string identifier

I am trying to serialize a C# const class into name-value pairs, which I need to access by their string names on the client side. For example: return $.parseJSON(constantClass).property; This approach is not working as expected. Is there any alternative ...

A Comprehensive Guide: Obtaining the Final Tab from a JSON using API

What is the method to extract the last tab from a given JSON code? { "claimed_levels": { "level_1", "level_2" } } I want to display the level when someone types "!levels". The desired output format should be: Your current level is "2" ...

`Must have content in file input in order to be saved to MongoDB`

When attempting to save a registry in MongoDB using Node.js, it seems that the operation fails if an image is not selected. I would like the inclusion of an image in this process to be optional, rather than mandatory. router.post("/", upload.single("image" ...

Leverage ngrepeat for iterating through a Set

One challenge I'm facing is working with the vm.s = new Set([1,2,3]) Is there a way to utilize ngRepeat on s without converting it to an array first? I've experimented with different approaches: <option ng-repeat="o in vm.s">{{o}}</op ...

Issue with AngularJS project unable to communicate with WebAPI project

I am a newcomer to the world of AngularJS and WebAPI. My Visual Studio 2015 setup includes two projects: EventViewer (AngularJS) and AppData (WebAPI). To host the website, I have configured IIS Express 7. The path for the website is set to the location of ...

Difficulty in toggling the visibility of the react-date-range picker package when selecting a date

I need assistance with a problem I'm facing. I am having trouble hiding and showing the react-date-range picker upon date selection. The issue is related to a package that I am using for date range selection. You can find the package link here - https ...

Are Ajax Caching and Proper Format Being Employed?

Can you help me with a JavaScript event that I have to call in this way: function addEvent(date, resId) { $("#appPlaceholder").load("/Schedule/Add?date=" + date.format()+"&resourceId="+resId, function () { $('#event ...

Can HTML text areas be designed to adjust their width automatically, as well as their height?

Among the numerous StackOverflow examples showcasing an auto-height Textarea, one noteworthy example can be found here: <textarea oninput="auto_grow(this)"></textarea> textarea { resize: none; overflow: hidden; min-heig ...

What is the process of integrating hegel.js with a React application created using create-react-app?

Have you heard of Hegel.js? It's a powerful type checker that I recently discovered. Surprisingly, there isn't much information online about using hegel.js with React. Check it out at ...

What is the process for sorting Google Map markers with AngularJS?

.controller('MapCtrl', ['$scope', '$http', '$location', '$window', '$filter', '$ionicLoading', '$compile','$timeout','$ionicPopup', function ...

The Highcharts Range Selector feature may encounter issues when used with multiple series

Currently, I am facing an issue with my highchart/highstock where I retrieve data from a PHP file. The problem arises when I attempt to use multiple series as the RangeSelector Buttons cease to function properly. For instance, in the example provided, the ...

Javascript code not running as expected

Check out this code snippet: function generateRandomTeams() { const prom = new Promise(() => { // ... console.log('teams', props.state.teams) // logs }) .then(() => { console.log('here') // doesn't log }) ...

Modify the variable for each VU in K6 (refresh token)

When I start my K6 test, I utilize my setup() function to obtain a token that will be used by every VU. I want each VU to have the same token, rather than generating individual tokens for each one. Although this works fine initially, the challenge arises ...

"Utilizing Angular's built-in functionality to enable drag-and-drop behavior on an element within

Currently, I am working with Angular and JSPlumb. My goal is to bind the draggable behavior from jsplumb to my element in the directive by using the element in the link function. This is how I currently approach it (http://jsfiddle.net/r8epahbt/): // In ...

What's the best way to group rows in an angular mat-table?

I am working on a detailed mat-table with expanded rows and trying to group the rows based on Execution Date. While looking at this Stackblitz example where the data is grouped alphabetically, I am struggling to understand where to place the group header c ...

Redux accesses the store data after a brief delay

I am new to using redux and I am currently working on implementing it for my very first project. Everything seems to be working fine, however, when I try to console.log the data from the redux store, initially it shows two empty arrays but in the subsequen ...