• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Angular JS error : controller not a function, got undefined

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I am learning Angular js and I am getting following error.

Error: [ng:areq] Argument 'Test123' is not a function, got undefined

Can somebody help me out with the same.
I am not able to resolve the problem and so not able to proceed.

following is the code from index.html


and following is the code from scriptCtrl.js




I have got no idea where I am going wrong, because the code looks pretty straightforward.



 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't just use any old function as a controller by name. What tutorial are you following?

You need to use the .controller() method of one of your AngularJS modules to declare a function as a controller.
 
Ranch Hand
Posts: 310
18
MS IE Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You first have to create a main module and load it with ng-app attribute, then create a controller in that module using controller method.

Here you can check an example I made for you: http://plnkr.co/edit/qF2BUr0FsVSe9dLztZPp?p=preview

I can recommend you this course to start with Angular: https://www.codeschool.com/courses/shaping-up-with-angular-js . It's interactive, simple, and you can learn pretty much from it.
reply
    Bookmark Topic Watch Topic
  • New Topic