what should i do Error: $controller:ctrlreg A controller with this name is not registered

I am running this code and getting an error

Error: $controller:ctrlreg
A controller with this name is not registered.

Any solution for this

Filename: app.js

var HeadCtrl = function($scope) {
    $scope.appDetails={
        title: "Bookart",
        tagline: "We have 1 million books for you "
    };
}

Filename : Bookkart.html

<!DOCTYPE html>
<html lang="en" ng-app>
<head>
    <meta charset="utf-8">
    <title>Bookkart</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="Bookkart.css"> 
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.8.2/angular.min.js"></script>
    <script type="text/javascript" src="app.js"></script>
</head>
<body>
        <div id="header-wrapper" ng-controller="HeadCtrl" >
            <span class="logo pull-left">{{appDetails.title}}</span>
            <span class="tagline pull-left">{{appDetails.tagline}}</span>
            <div class="nav-wrapper pull-left">
                <ul class="nav nav-pills">
                    <li class="active"><a href="#">Books</a></li>
                    <li><a href="#">Kart</a></li>
                </ul>
            </div>
        </div>
</body>
</html>

10 thoughts on “what should i do Error: $controller:ctrlreg A controller with this name is not registered”

  1. Try instantiating your controller like this

     angular.module('app').controller("HeadCtrl", function($scope){
          $scope.appDetails={
          title: "Bookart",
          tagline: "We have 1 million books for you "
          };
    });
    
    Reply

Leave a Comment