angular NaNunction%2C%20got%20undefined exception

Looks like it's having trouble finding SearchController all together. Is your SearchController in its own file? If so, be sure to load it in your index.html!

So,

 <script src="scripts/lib/angular.min.js"></script>
 <script src="scripts/lib/angular-route.min.js"></script>
 <script src="scripts/lib/bootstrap.min.js"></script>
 <script src="app.js"></script>
 <script src="path/to/controller/SearchController.js"></script>

EDIT: Ah, I see the issue. You have not yet defined "SearchController" in your app.js.

To do this -

In SearchController.js, change angular.module('mainApp') to angular.module('SearchController') Understand you are creating an angular module that is not yet apart of your 'mainApp' module.

Then, in your app.js, do var mainApp = angular.module('mainApp', ['ngRoute', 'SearchController']); This will properly inject your controller into your app, and it can be used correctly by your router.

Tags:

Angularjs