Fixing AngularJS $routeProvider JSHint issues

I need help with this angular script

    (function() {
        'use strict';

        var myApp = angular.module('MyApp', [
            'ngRoute',
            'MyApp.controllers.Main'
        ]);

        myApp .config(['$routeProvider',
            function($routeProvider){
                $routeProvider.

                    when('/',{
                        templateUrl: '../templates/home.html',
                        controller: 'homeController'
                    }).

                    when('/one',{
                        templateUrl: '../templates/one.html',
                        controller: 'oneController'
                    }).

                    when('/two',{
                        templateUrl: '../templates/two.html',
                        controller: 'twoController'
                    });
        }]);
        
    })();

After running jshint, I encountered the following errors:

    src/app/app.js: line 27, col 5, Expected an identifier but found '}'.
    src/app/app.js: line 27, col 5, Expected an assignment or function call but got an expression instead.
    src/app/app.js: line 27, col 6, Semicolon missing.
    src/app/app.js: line 27, col 6, Expected an identifier but saw ']'.
    src/app/app.js: line 27, col 6, Expected an assignment or function call but got an expression instead.
    src/app/app.js: line 27, col 7, Semicolon missing.
    src/app/app.js: line 27, col 7, Expected an identifier but found ')'.
    src/app/app.js: line 27, col 7, Expected an assignment or function call but got an expression instead.
    src/app/app.js: line 29, col 2, ']' should match '[' from line 9 but found ')'.
    src/app/app.js: line 29, col 5, ')' expected but '; found.
    src/app/app.js: line 29, col 6, Semicolon missing.
    src/app/app.js: line 1, col 13, Opening brace not matched.
    src/app/app.js: line 29, col 10, Unrecoverable syntax error. (100% scanned).

I'm struggling to understand how to fix these jshint errors in my angular code.

Answer №1

    when('/two',{
                    templateUrl: '../templates/two.html',
                    controller: 'twoController'
                });

The final "." ought to be replaced with a ";" in order for it to appear as follows:

     when('/two',{
                    templateUrl: '../templates/two.html',
                    controller: 'twoController'
                });

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

Encountering a blank page and error message on Vue JS while attempting to generate a JSON file within the

Recently, I encountered a peculiar problem while working on my Vue project using Vue UI in Visual Studio. Before connecting my API, I wanted to prototype and experiment with fake data. So, I decided to create a JSON file in the assets folder to store my m ...

Selenium unfortunately does not fully function with JavascriptExecutor

When I attempt to input text using JavascriptExecutor, the code snippet below is what I use: private void inputWorkDescription(WebDriver driver, int rawNumber) throws IOException, GeneralSecurityException { if (!getWorkDescriptionFromSheets(rawNum ...

Troubleshooting: Why Your Angular Data Binding is Failing

I am integrating a WCF REST service with an AngularJS application. My goal is to retrieve account information based on the account number provided, however, I am encountering an issue where the text "Account_Type" is displayed three times before showing th ...

Prevent users from deleting options in Autocomplete by disabling the backspace key

I am currently working on implementing the Autocomplete component from Material-Ui library to allow users to select multiple options, but I want to restrict them from directly removing any of those options. One issue I've encountered is that users ca ...

Styling select input forms with Bootstrap 3

I'm looking to create a select dropdown menu that matches the style of other inputs in a bootstrap 3 form. You can view an example of what I want to achieve on this plunker or see the image below: This CSS code is included in the header: <!-- Boo ...

Executing a Python function using JavaScript: Step-by-step guide

I am facing an issue with invoking my python function from my javascript file. Running a simple server with python3 -m http.server, I have no backend and all my javascripts are on the front end. In a python file named write.py, there is a function that I ...

Obtain the JSON response from the servlet

Is there a way to get a JSON response from a servlet in JavaScript? I am using AJAX post to send data to the servlet. Here is my AJAX code $.ajax({ type: "POST", url: "formDelegationServlet", data: { ...

ocModal not updating properly due to binding issue

I have implemented the ocModal directive + service (https://github.com/ocombe/ocModal) in my project. The functionality allows users to delete a record by clicking a delete button, which triggers a modal confirmation window through ocModal. oc-modal-close ...

Discovering whether input field is currently in focus using jQuery

Does anyone know how to determine if an input tag in HTML has focus using jQuery? The keydown event will function for forms when input, image, etc. tags have focus. However, it will not work if the focus is on the form itself but not on any specific tags ...

Learn how to combine items with matching names and calculate the total of their values in key value1 and value2 using JavaScript

In my array, I have a collection of objects that contain details about people and cars: const arrayData = [ {name: 'John', car:'BMW', value1: 500, value2: 350}, {name: 'Paul', car: 'AUDI', value1: 290, value2: 200 ...

Could you provide me with a demonstration of cross-domain functionality?

Similar Inquiry: Methods to bypass the same-origin policy Let's consider two domains for this example - "" and "". The first domain "" is generating data in JSON format as shown below: { "str_info": [ { "str_name": "Mark ...

Ways to navigate to a specific list-group-item using JavaScript

I am working on a bootstrap list-group with a vertical scrollbar and fixed height. The issue I am facing is that the active item is selected programmatically during group creation, but it ends up being out of view when the list is displayed. Is there a wa ...

Dealing with lag problems while feeding a massive dataset into the Autocomplete component of Material-UI

In my React project, I have integrated the Autocomplete component from Material-UI to enhance user experience. However, when attempting to pass a large dataset of 10,000 items to the Autocomplete component as a prop, there is a noticeable delay of approxim ...

extracting generated hyperlinks through a JavaScript function via webdriver

Looking for help with accessing a tricky href that cannot be hardcoded due to dynamic generation: Base classes https://gist.github.com/codyc4321/724f05aca8f6775e2fc1 (access_link of interest) class HCCDriver(FirefoxDriver): def __init__(self, userna ...

The UseEffect function ceases to function properly upon refreshing the website

I'm currently using ReactJS for a project. I have a form that is intended to serve as the configuration for another form. The structure of this specific form is as follows: const [startingDate, setStartingDate] = useState(); const [endingDate, set ...

Mastering the use of expressions in ng-click and ng-show in AngularJS

I've been working on creating expandable rows within a table, but I'm encountering some issues. Despite not receiving any error messages, the functionality isn't behaving as expected. I suspect there might be an issue with how I'm using ...

How can you incorporate a value into a variable in PHP?

Hey there! I'm pretty new to PHP and I've been working on building a program that resembles a spreadsheet. My form consists of columns and cells, allowing users to add or delete rows using Javascript. The challenge I'm facing is automating t ...

Extract data from JSON using the parse function

After utilizing the function JSON.stringify(), I have obtained this JSON: {"get":"function (f,g){'use strict';var h,i;if(i={},'string'==typeof f){if('object'==typeof g)for(h in g)i[h]=g[h];i.url=f}else if('object'== ...

Comparison between Next.js and Express.js

As I delve into the world of Node.js backend development, I find myself at a crossroads between Next.js and Express.js for my next project. I have some familiarity with Express.js, particularly for API development, but I'm a bit confused about Next.js ...

Establishing the Time-to-Live (TTL) with Redis-OM and Node Object Mapping

Recently, I stumbled upon the exciting new Redis-OM Node Object Mapping feature. Although I have limited experience with Redis, I am eager to dive into it now. Currently, I have a basic function in place for creating rooms but I want these rooms to automa ...