Fixing SCRIPT1028 error in IE9 with the help of AngularJS

Utilizing AngularJS in my single-page application, I have a button defined as follows:

<button class="btn btn-success" onclick="doSeekTo({{todo.position}});doPlay();">

When this button is clicked, it triggers the javascript function with the specified parameter enclosed in double curly braces, standard practice in AngularJS.

While this functionality operates smoothly in IE9, the error console shows "Expected identifier, string or number" at the location of the curly braces.

How can I resolve this error? It's quite unsettling for me.

Answer №1

When working with Angular, it is recommended to avoid using the standard onclick event and instead utilize Angular's ng-click event. This allows for a cleaner approach when coding like this:

ng-click="navigateTo(page.section);executeAction()"

Answer №2

When IE9 parses the HTML before your angularjs code can make modifications, it may be helpful to introduce some form of indirection like this...

<button class="btn btn-success" paramvalue="{{todo.position}}" onclick="doSeekTo(this.paramvalue);doPlay();">

Answer №3

If you want to ensure compatibility with IE, you can place the {{}} within single quotation marks to make it a string:

<button class="btn btn-success"> onclick="doSeekTo('{{todo.position}}');doPlay();">

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

The MEAN.JS platform encountered an issue with the Route.all() function, as it was expecting a callback function but instead

I am currently exploring the MEAN Stack and have been experimenting with meanjs.org yo generator in version 4.1. The CRUD example was included in the generated app, which I utilized as a reference for my own code. Upon execution, I encountered the followi ...

Utilizing the Twitter API variable within ExpressJS while incorporating AngularJS

Using the "twit" Twitter package from GitHub, I am able to call the Twitter API and retrieve data that is logged in the console. However, I am unsure of how to pass this data to AngularJS in order to display the tweets on the front-end. T.get('search ...

Bits of code and the internet

When it comes to displaying code on the web, there are a few key steps involved: Encoding HTML entities Formatting The most basic workflow would involve: Start with a code snippet like: <html> I'm a full page html snippet <html>. ...

Generate a nested array structure from an existing array using JavaScript

Currently, I have an array of numbers: [12345,345653,456356]. However, I need to convert this to a format like [[1232131],[234324],[67657]] in order to use a CSV react component tool that reads data in this specific structure. Does anyone have any ideas ...

Upon removing an element, the button click event fails to trigger

I recently created a div that looks like this <div id="hidden"> <img src="photos/Close-2-icon.png" width="16" height="16"> <input id="add" value="Add field" type="button" > <input type='button' id=&a ...

What if we started transmitting JavaScript files as browser-specific bytecode instead?

While there is no universal bytecode for JavaScript, most JavaScript engines have their own bytecode. The source code string of JavaScript files must be parsed/compiled into bytecode before execution. Could servers store bytecode for different browsers an ...

Disabling specific time slots in the mat select functionality

I have a scenario where I need to display time slots at 30-minute intervals using Mat Select. export const TIME=["12:00 AM","12:30 AM","01:00 AM","01:30 AM","02:00 AM","02:30 AM","03:00 AM&qu ...

Transforming JSON data into a hierarchical tree structure in JSON format

I have a JSON treeData that I need to convert into a different format so that I can use a visualization library in JavaScript. treeData={ "leftNode": { "leftNode": { "leftNode": { "leftNode": { ...

Programming the tab pages within Chrome

By using JavaScript, I successfully opened a new tab at www.blogger.com from the Main.html page. <script> window.open("https://www.blogger.com"); </script> I am now on the blogger page. My goal is to automatically scroll to the end of the bl ...

Display the div according to the $index selected from the AngularJS list

Below is the structure of my HTML code: <div class="col-md-4"> <ul class="list-group text-left"> <a href="#" class="list-group-item" ng-click="showData($index)" ng-repeat="field in Data"> {{ field.name }}</a> ...

What are the steps to resolve issues with my API in a Kendo grid using AngularJS?

I am trying to integrate my API with AngularJS using Kendo, but I am encountering an error. Here is a snippet of my code: scope.mainGridOptions = { dataSource: { type: "odata", transport: { read: { ...

Are there any alternatives to using the $size function in MongoDB for this specific tier in Atlas?

I am trying to create a code that will return certain data only if there are exactly 2 instances of the by field in the data array. The number of _id entries can vary. Unfortunately, using { $size: { data: 2 }, } doesn't work as I am encountering an ...

Retrieve information from a JSON API on one server and showcase it on an HTML page hosted on a different server

I have a situation where I need to transfer data from one project (Project1) to another project (Project2). To achieve this, I decided to convert the Project1 data stored in a database into a JSON API and then call it using an HTML page from Project2. Howe ...

Sending a variety of data inputs to an API using ajax

I am a beginner in coding and facing some challenges in troubleshooting an issue. My goal is to allow my API to accept multiple data inputs provided by the user through textarea. However, I have encountered a problem where everything works fine when only ...

Is it possible to include two of these on a single page with unique variables? (Using JQuery)

I am looking to create two similar pages, each with different percentages. However, when I try modifying the JS or changing class/ID names, it keeps pulling data from the first SPAN element. http://jsfiddle.net/K62Ra/ <div class="container"> <di ...

Let's update the VUE app's development server to point to my-testing-web-address.com instead of the default localhost:

I am working on a VUE application and I am trying to run it on an external link instead of localhost. I attempted to configure a vue.config.js devServer: { host: 'http://my-testing-web-address.com', port: 8080, ... } and adjusted t ...

My authentication process involves utilizing auth0 for verifying users, coupled with an API designed for creating, reading, updating, and deleting posts which include fields for titles, images, and descriptions. What steps should be

I am currently in the process of developing a react application and have implemented auth0 for user authentication. Prior to integrating auth0, I was sending CRUD requests to my API to create posts without any user authentication in place. Now that I have ...

What is the best way to include a MongoDB match argument when it is received from the frontend, and to exclude it if it is not provided?

I'm currently working on creating an aggregation in MongoDB using NodeJS. The goal is to add an argument to the MongoDB match function if it exists when the resolver function is called. However, I'm encountering an issue where if no addition is m ...

Generating an interactive button click feature within a cell of a data table

Can someone help me figure out why I am getting a SyntaxError when trying to trigger a function in a datatable cell using an onclick event on a button? The button is successfully created, but the error occurs when clicking it. The problem seems to lie wit ...

Tips for utilizing sendToDevice multiple times in a function return value

In my Firebase Cloud Functions script, I have successfully implemented sending push notifications to users using a specified set of token arrays returned by a function: return getTokens(array1).then(tokens => { return (admin.messaging().sendToDevice( ...