I am continuously encountering an error message saying [$injector:modulerr] while working with AngularJS

I've been reviewing my JavaScript code thoroughly, but I can't seem to pinpoint any major issues. The error message I'm encountering is as follows:

Uncaught Error: [$injector:modulerr] Failed to instantiate module careApp due to:
Error: [$injector:nomod] Module 'careApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

I have double-checked and confirmed that I am using the correct modules and dependencies. Everything seems to be correctly spelled and in order.

I suspect the issue may lie within the $routeProvider section of my JavaScript code...

'use strict';

(function() {

  var AppCtrl;
  AppCtrl = function() {
    function AppCtrl($scope) {
      $scope.list = [{
        label: 'Main Menu',
        icon: 'fa fa-home fa-fw 4x',
        link: '#/homePage',
        move: function() {
          console.log("HOME");
        }
      }, {
        label: 'Patient',
        icon: 'fa fa-user fa-fw 4x',
        link: '#/pCredential',
        move: function() {
          console.log("PATIENT");
        }
      }, {
        label: 'Technician',
        icon: 'fa fa-user-md fa-fw 4x',
        link: '#/tLogin',
        move: function() {
          console.log("TECHNICIAN");
        }
      }, {
        label: 'Administrator',
        icon: 'fa fa-cogs fa-fw 4x',
        link: '#/aLogin',
        move: function() {
          console.log("ADMINISTRATOR");
        }
      }];
    }
    return AppCtrl;
  }();

  angular.module('careApp', [
      'ngRoute',
      'ngMaterial',
      'ngAria',
      'ngAnimate'
    ])
    .config(['$routeProvider', function($routeProvider) {
      $routeProvider
        .when('#/homePage' {
          template: '<p>WELCOME HOME!</p>'
        }).
      when('#/pCredential' {
        template: '<p>INSERT CREDENTIALS INTO NODE.</p>'
      }).
      when('#/tLogin' {
        template: '<p>PLEASE LOGIN TO THE TECHNICIAN PAGE.</p><p>GET CREDENTIALS FROM OWNER.</p>'
      }).
      when('#/aLogin' {
        template: '<p>ADMINISTRATOR ACCESS.</p>'
      })

      //load default page on page refresh
      .otherwise({
        redirectTo: '/appLaunch'
      });
    }])

  .controller('AppCtrl', ['$scope', AppCtrl]);

}());

To view the current Fiddle, click here: https://jsfiddle.net/Miega/mowwckze/3/

If anyone could offer assistance, it would be greatly appreciated.

Answer №1

Don't forget to add commas after the first parameter in each of your .when route declarations.

$routeProvider
  .when('#/homePage', {
    template: '<p>WELCOME HOME!</p>'
  }),
  when('#/pCredential', {
    template: '<p>INSERT CREDENTIALS INTO NODE.</p>'
  }),
  when('#/tLogin', {
    template: '<p>PLEASE LOGIN TO THE TECHNICIAN PAGE.</p><p>GET CREDENTIALS FROM OWNER.</p>'
  }),
  when('#/aLogin', {
    template: '<p>ADMINISTRATOR ACCESS.</p>'
  })

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

Utilizing a TypeScript function to trigger an action from within a Chart.js option callback

Currently, I am utilizing a wrapper for Chart.js that enables an animation callback to signify when the chart has finished drawing. The chart options in my code are set up like this: public chartOptions: any = { animation: { duration: 2000, ...

Creating Transparent Rounded Backgrounds in Google Chrome Packaged Apps: Achieving the same look as Google Hangout app

Looking at the screenshot below, it is evident that the Hangout app has a fully transparent design with background shadow effect applied to it. I have tried various methods in vain, such as applying CSS styling to the "html" and "body" tags of the page, a ...

Oops! The angular app encountered an error: TypeError - it cannot read property '0' of undefined. Time to debug

Having difficulty grasping the source of an error, as the html side is able to read list[3].main.temp without any issues. However, in the second loop of the generateList function, I encounter an error specifically on $scope.list[i].main.temp, which throws: ...

Issue with nested directive not triggering upon page load

I recently started working with AngularJS and came across an issue with nested directives. In my project, I have two directives: MainDir.js (function(){angular.module("mod").directive("mainDir", function(){ return { restrict: "E", scope: {}, ...

Creating synchronous code that includes a promise involves structuring your code in a way

Here is a function that I am currently working with: var send = function send (report) { someAsnycFn().then( function () { synchronousSend(report); return true; }, function () { ...

Receiving the latest global variable in JavaScript using jQuery

I keep receiving undefined type for: $(".ui-slider-handle").attr("title", '"'+current+'"'); Even though I can successfully alert the updated value of current on line 29, it seems to not be working with .at ...

Managing dynamically appearing elements in Ember: Executing a Javascript function on them

I'm currently working on a project in Ember and facing an issue with calling a JavaScript function when new HTML tags are inserted into the DOM after clicking a button. Below is a snippet of my code: <script type="text/x-handlebars" id="doc"&g ...

This error message 'React Native _this2.refs.myinput.focus is not a function' indicates that

When working with React-Native, I encountered a specific issue involving a custom component that extends from TextInput. The code snippet below demonstrates the relevant components: TextBox.js ... render() { return ( <TextInput {...this.props} ...

Transferring request body data between routes in Express: A guide

In my MERN application, there are two specific routes in place. The first route is designated for 'Storing Data' and is referred to as the 'data' route. The second route is used for 'Register User' functionalities and is known ...

AngularJS stores AJAX data in a service for easy access

My scenario is quite simple: https://i.stack.imgur.com/Vmxqu.jpg The app begins at the Main View (/main), then the user clicks on the button in the top right corner to go to the Sub View (/sub). Upon launching the app with app.run(), the user's pro ...

Include onload to element without running it in Puppeteer

I am currently developing a web scraping tool using Puppeteer. Once the webpage is fully loaded, I need to update the HTML code and include an onload event for certain elements. The issue is that in Puppeteer, the onload event is actually triggered automa ...

What is the optimal approach for managing server-side data stored as a JavaScript variable?

When dealing with global variables like JSON inserted into a web page server side with PHP, the best way to handle it is up for debate. Options might include leaving it for garbage collection, omitting var initialization and deleting the variable, or simpl ...

The double click feature is not functioning properly when used in conjunction with the selectpicker Boostrap

<select class= "selectpicker" id="cus_id"> <option value="654" >test1</option> <option value="6877" >test2</option> <option value="8687" >test3</option> </select ...

JavaScript drop-down menu malfunctioning

I am currently in the process of learning web development languages, and I'm attempting to create a dropdown list using JavaScript (I previously tried in CSS without success). I would greatly appreciate it if you could review my code and let me know ...

JQuery addClass function not functioning properly when used in conjunction with an AJAX request

I have a website where I've implemented an AJAX pagination system. Additionally, I've included a JQUERY call to add a class to certain list items within my document ready function. $(document).ready(function(){ $(".products ul li:nth-child(3 ...

Kendo UI Web - MultiSelect: choosing an option multiple times

Currently, I am encountering an issue with the Kendo UI MultiSelect widget when trying to select an option multiple times. An example of this is shown in the image below where I want to choose Schindler's List again after selecting The Dark Knight. Ho ...

Creating a button that integrates an image within a single div element

Currently, I understand the code: $('#leftDev').css("background-image", "url(img/1.png) "); will set the entire background of my leftDiv to display "1.png". However, I would like to position this image as a regular picture within the div and no ...

The implementation of pushing inside a foreach loop is not correctly adding elements to

I have encountered an issue with running a foreach loop and adding values to an array in my code. The first foreach loop works as expected, adding values properly to the array. However, the second foreach loop seems to be malfunctioning as none of its valu ...

Can you clarify the purpose of response.on('data', function(data) {}); in this context?

I am curious about the inner workings of response.on("data"). After making a request to a web server, I receive a response. Following that, I utilize response.on("data" ...); and obtain some form of data. I am eager to uncover what kind of data is being p ...

The react-leaflet-heatmap-layer-v3 source directory could not be located

Upon attempting to utilize the npm package react-leaflet-heatmap-layer-v3 in my React TypeScript application, I successfully installed it and ran yarn start. However, I encountered the following warning messages: WARNING in ./node_modules/react-leaflet-hea ...