0

I have several problems in the console and i'm unsure on how to fix.

The first error I am getting is

angular.js:68 Uncaught Error: [$injector:nomod] Module 'reviewsApp' 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.

along with ...

angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module reviewsApp due to: Error: [$injector:nomod] Module 'reviewsApp' 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.

Can someone advise what I am doing wrong???

I have a simple controller like the following with the html at the bottom (Please not these files are separate in my project)...

(function() {
'use strict';

angular
    .module('reviewsApp')
    .controller('ReviewsController', ReviewsController);

ReviewsController.$inject = ['$http'];

function ReviewsController ($http){
    var vm = this;

    var onReviewComplete = function(response) {
        vm.reviews = response.data;
    };

    var onError = function(reason) {
        vm.error = reason.data;
    };

    $http.get('../DataService/services/reviews/getReviews.php')
        .then(onReviewComplete, onError);

    //Insert Review
    vm.insertReview = function(review){

        //Create review object.
        var reviewObj = {
          'name' : review.name,
          'message' : review.message
        };

        var insertRequest = $http.post('xxnx.com', reviewObj);

        insertRequest.success(function(data, status, headers, config) {
            vm.showSuccessAlert = true;
            vm.clearForm(review)
        });

        insertRequest.error(function(data, status, headers, config) {
            vm.showFailAlert = true;
        });
    };

    vm.clearForm = function (review){
        review.name = "";
        review.message = "";
    };
}

})();

<div class='container-fluid' ng-app='reviewsApp' ng-controller='ReviewsController'>

        <div class='container'>

        <div class='row'>
            <h1 class='col-md-12 review-main-heading'> Reviews </h1>
        </div>

        <div class='row'>
            <div class='col-md-9'>
1
  • you need to instantiate your module like .module('reviewsApp', []) and put dependancy inside [] Commented Aug 3, 2016 at 16:29

2 Answers 2

1

You need to add the [] to mention the dependencies too,

Change

From

angular.module('reviewsApp')
    .controller('ReviewsController', ReviewsController);

To

angular.module('reviewsApp',[])
    .controller('ReviewsController', ReviewsController);
Sign up to request clarification or add additional context in comments.

Comments

1

Try like this:

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

reviewsApp.controller('ReviewsController',['$scope', '$http' function($scope, $http) {

// Your own code which is in - "function ReviewsController(){}" - comes here

}]);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.