I am getting following error
Error: [ng:areq] Argument 'nameController' is not a function, got undefined http://errors.angularjs.org/1.3.7/ng/areq?p0=nameController&p1=not%20a%20function%2C%20got%20undefined
at REGEX_STRING_REGEXP (angular.js:63)
at assertArg (angular.js:1575)
at assertArgFn (angular.js:1585)
at angular.js:8416
at angular.js:7590
at forEach (angular.js:331)
at nodeLinkFn (angular.js:7577)
at compositeLinkFn (angular.js:7073)
at compositeLinkFn (angular.js:7076)
at publicLinkFn (angular.js:6952)
I tried to change the version of angular to lower one and also used CDN but it didn't work. Tried checking syntax error as well.
Is my function declartion correct? How to resolve this error.
[Plunkr][1]
http://plnkr.co/edit/HcPXYTb5p6wrsDobdGFg?p=previewenter code here
After angular 1.3, you could not use global declaration of angular controller. For fixing this issue you need to create angular module first and then assign the angular component to it like controller, directive, service, factory, filters, etc.
// Code goes here
angular.module('app',[])
.controller('nameController', nameController)
function nameController($scope) {
$scope.firstName = 'allen';
$scope.lastName = 'martin';
}
then use the created module on ng-app="app"
in your html.