AngularJS controller not found, for undefined

I get an AngularJS error with an error when starting the following example, please let me know where I am doing wrong? Actually the following code works fine if I run outside / fine, but when I copy / paste this code into my application, it gives the following error. (this page / tab is displayed from my application controller, for example: TestController, which is available in coffeescript, but I don’t need any coffeescript for this requirement, I need it in AngularJs. So, on this tab I need to display below the code / button .

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <script> var myApp = angular.module('myApplication', []); myApp.controller('TestController', ['$scope', function($scope){ $scope.test = function(){ alert("Success"); } }]); </script> </head> <body> <div ng-app="myApplication"> <div ng-controller="TestController"> <div class="tab-pane" id="wizards"> <button type="button" ng-click="test();">Test</button> </div></div></div> </body> </html> 

Error: Error: [ng:areq] http://errors.angularjs.org/1.4.8/ng/areq?p0=TestController&p1=not%20a%20function%2C%20got%20undefined

+5
source share
1 answer

This plunker works for me

 <head> <link rel="stylesheet" href="style.css"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.5/angular.min.js"> </script> <script src="script.js"></script> </head> <body> <div ng-app="myApplication"> <div ng-controller="WizardController"> <button ng-click="test()">Test</button> </div> </div> </body> 
+2
source

Source: https://habr.com/ru/post/1237826/


All Articles