What steps can I take to resolve the Angular JS error message: [$injector:unpr]?

index.html

<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
    <meta charset="UTF-8">
    <title>Angular JS</title>
    <script src="lib/angular.min.js"></script>
    <script src="lib/angular-route.min.js"></script>

    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <link rel="stylesheet" href="css/style.css" />
</head>
<body>
    <div class="main" ng-view></div>
</body>
</html>

list.html

<ul class="artistlist">
    <li class="artist cf" ng-repeat="item in artists | filter:artistFilter | orderBy:artistOrder:direction">
        <img ng-src="images/{{item.shortname}}_tn.jpg" alt="{{item.name}}">
        <div class="info">
            <h2>{{item.name|uppercase}}</h2>
            <h3>{{item.reknown}}</h3>
        </div>
    </li>
</ul>

app.js

var myApp = angular.module('myApp',['ngRoute','artistControllers']);

myApp.config(['$routeProvider', function($routeProvider) {
    $routeProvider.when('/list', {
        templateUrl: 'partials/list.html',
        controller: 'ListController'
    }).otherwise({
        redirectTo: '/list' 
    });
}]);

controllers.js

var artistControllers = angular.module('artistControllers', []);

artistControllers.controller('ListController', ['$scope', '$http', function($scope, $http) {
    $http.get('data.json').success(function(data) {
        $scope.artists = data;
        $scope.artistOrder = 'name'
    });
}]);

full error

Error: [$injector:unpr] http://errors.angularjs.org/1.2.9/$injector/unpr?p0=%24templateRequestProvider%20%3C-%20%24templateRequest%20%3C-%20%24route%20%3C-%20ngViewDirective
    at Error (native)
    at http://localhost/angular/lib/angular.min.js:6:449
    at http://localhost/angular/lib/angular.min.js:32:125
    at Object.c [as get] (http://localhost/angular/lib/angular.min.js:30:200)
    at http://localhost/angular/lib/angular.min.js:32:193
    at c (http://localhost/angular/lib/angular.min.js:30:200)
    at Object.d [as invoke] (http://localhost/angular/lib/angular.min.js:30:417)
    at http://localhost/angular/lib/angular.min.js:32:211
    at c (http://localhost/angular/lib/angular.min.js:30:200)
    at Object.d [as invoke] (http://localhost/angular/lib/angular.min.js:30:417)

Answer №1

Gratitude for sharing the error message. It made locating the error much easier.

I believe this resource could assist you further:

(It appears to be a discrepancy in angular/ngRoute versions)

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

Issues with Firefox Protractor testing functionality

Trying to test a protractor on an angularjs application using Firefox 47 has been unsuccessful. Attempted downgrading to version 46.0.1 after researching on Stack Overflow, but still facing issues. Has anyone discovered a working solution for this? It seem ...

I'm really confused as to why I am receiving an undefined error in this code. Can someone please assist

I'm encountering an issue with getting undefined in this section of code. Is there a way to fetch the data using useEffect, and once everything is loaded, how can I efficiently store it in a useState variable and then display the necessary content? co ...

Advantages of using $apply(fn) instead of $apply() in AngularJS

Currently, I am exploring a blog post about Angular tips that discusses how the $apply function runs a digest cycle. You can check it out here: The blog also explains a better way to use $apply in a directive link function: element.bind('click' ...

Toggle the status of active to inactive instantaneously with the click of a

Incorporating DataTables with ajax using PHP CodeIgniter Framework has presented me with a challenge. I am struggling to toggle between Active and Inactive buttons seamlessly. My desired outcome: When the Active button is clicked, it should transition ...

"Enhance your Angular experience with SweetAlert integration using directives and translation

Currently, I am utilizing the Angular implementation of the SweetAlert plugin from GitHub. I am attempting to pass an Angular directive with translation to the title. The variable being passed as the title is: {{ 'register.confirmation_modal.SUPERI ...

Revise directive following the dynamic addition of elements

My Objective: I aim to utilize directives for creating custom elements and dynamically inserting them into the view at various points in time. The Challenge: Upon dynamically adding custom elements to the view, they appear as raw HTML without the directi ...

Leverage JSON data using props in React JS

Currently, my data is formatted in JSON and successfully populated into props known as foxFooterData. Upon inspecting the console.log result of foxFooterData.data, the following information is visible: I am attempting to retrieve the foxFooterCopyright t ...

Issue with AngularJS: Dynamically generated tab does not become active or selected

Exploring an AngularJS code snippet that generates tabs upon clicking the new button. However, there's an issue where the newly created tab doesn't become active or selected automatically after creation. It seems like the one before the last tab ...

What is the best way to retrieve all collections and their respective documents in Firestore using cloud functions?

Seeking to retrieve an array structured as [1year, 1month, etc] with each containing arrays of documents. Currently encountering a challenge where the returned array is empty despite correct snapshot sizes. Unsure if issue lies with push() method implemen ...

Invoking code behind functions through ajax requests to dynamically display items one by one

I'm currently working with calling code behind functions from an ajax call. I have recently developed a method called Post, which returns a list of values. My goal is to verify these values from the client side by displaying them in an alert message. ...

Creating numerous Facebook posts using jQuery technology

I am currently facing a challenge when attempting to publish multiple facebook posts on a webpage using jQuery. Although I have managed to successfully post the first facebook post, I am encountering difficulties when trying to post another one. What coul ...

All menus effortlessly sliding out simultaneously

I'm having an issue with my navigation bar. I want each link to slide its corresponding DIV up or down when clicked. However, all the DIVs are sliding and when clicking on the same link everything slides up. How can I fix this problem? This is my HT ...

Transform the MUI Typescript Autocomplete component to output singular values of a specific property rather than a complete object

When utilizing MUI Autocomplete, the generic value specified in onChange / value is determined by the interface of the object set in the options property. For instance, consider an autocomplete with the following setup: <Autocomplete options={top ...

The 'export '__platform_browser_private__' could not be located within the '@angular/platform-browser' module

I have encountered an issue while developing an angular application. Upon running ng serve, I am receiving the following error in ERROR in ./node_modules/@angular/http/src/backends/xhr_backend.js 204:40-68: "export 'platform_browser_private' w ...

Utilizing App Script for Filtering Data with Multiple Criteria

Having trouble transferring data from a data sheet to my report sheet using multiple criteria for matching. I wrote some code that worked, but it's returning all data instead of filtering by criteria. I want the function to search for column criteria ...

Function activation in Element requires a double click to initiate

I've encountered an issue with a web element I'm working on where the click function only triggers after the first click, rendering the initial click ineffective. Here's the code snippet in question: HTML: <div> <a href="#0" cla ...

It is impossible to alter the data contained within the input box

Objective: Upon clicking a button to display the modal, the selected data (first and last name) should be inserted into an input box and editable. The user should be able to modify the data. Issue: The data entered into the input box cannot be edited ...

Unexplainable space or padding issue detected in OwlCarousel grid gallery

There seems to be an unusual gap or margin at the bottom of each row section in this portfolio grid gallery that's running in OwlCarousel. You can view an example here. https://i.stack.imgur.com/NHOBd.png I've spent a lot of time trying to solv ...

Can an Expression be incorporated into the ng-model Directive?

I am facing an issue with my loop: <div ng-repeat="measure in CompleteDataSetViewModel.TargetMeasures"> </div> Within this loop, I have an input field: <input ng-model="CompleteDataSetViewModel.AnnualRecord.Target[measure.Name]_Original" ...

New Trainee - Error: document has not been defined

Encountering an Error message while attempting to run Intern tests from the test files directory. The structure of the directory is as follows: test resources rest pickup.js cashManagement.js gitignore intern.js packages.js ...