AngularJS Error: The controller with the name myCtrl is not registered

Last Reply on Jan 29, 2018 02:18 AM By dharmendr

Posted on Jan 29, 2018 02:09 AM

I am getting error in console that my controller is not registered.

<!DOCTYPE html>
<html>
	<head>
		<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
	</head>
	<body>
		<div ng-app="myApp" ng-controller="myCtrl">
		    <div>
		    	<h1>Add Your Quotes</h1>
		    </div>
		    <div>
		    	<button name=addQuote ng-click = "addQuoteBtn()">Add Quote</button>
		    </div>
		    <div ng-if="isVisible">
		    	<textarea rows="4" cols="50" placeholder="Add Quotes Here"></textarea>
		    </div>
		</div>
		<script>
			var app = angular.module('myApp', []);

			app.controller = ('myCtrl', ['$scope', function($scope){
				$scope.isVisible = false;
				$scope.addQuoteBtn = function(){
					$scope.isVisible = true;
				}
			}]);
		</script>
	</body>
</html>

 

This question does not have replies that have been liked.