I was getting the error because i had added the controller script before the script where i had defined the corresponding module in the app. First add the script
<script src = "(path of module.js file)"></script>
Then only add
<script src = "(path of controller.js file)"></script>
In the main file.