AngularJS TypeError: object is not a function

The error msg in Chrome Dev Tools. “TypeError: object is not a function”

Update: I found out the problem! Woohoo… see below.

Image

Error happens when I click the submit button on a form. It doesn’t even get to the controller function so I’m thinking it’s an internal error to Angular 1.2.9 somewhere.

The error in Firefox: “Error: fnPtr is not a function”

Image

On further inspection it seems it’s this code.

Image

Now this looks like some IE fix (obviously) so why the hell is it breaking???

Notes:
I’m using Lineman Angular Template so maybe it’s calling $q.all somewhere and causing the issue to surface? Either way it’s stopping my form from working….

Upgrades:
I’ve tried upgrading to Angular 1.2.15 and I get the same error.
And unstable version 1.3.0-beta.4 same result.

Cause:

For some reason it doesn’t like the “name” property on the form… why? Maybe Angular can’t handle the name on the form when it’s binding or something.

But when you remove that it works fine.

Now the login() function in the controller is being called as normal.

Image

refs:

Sam Deering

Sam Deering

Sam is a web developer, online entrepreneur and investor. In his spare time he enjoys coding, playing chess and sharing what he learns with others.

11 thoughts on “AngularJS TypeError: object is not a function

  1. `For some reason it doesn’t like the “name” property on the form… why? Maybe Angular can’t handle the name on the form when it’s binding or something.`
    – The name attribute of a form element creates a variable $scope.login in the current scope, and thereby overwritting your method ($scope.login = function() ..)
    Try validating your form. It will make sense.

    1. Ah, that makes sense yes. It sucks it overwrites the declared login() method but is Angular’s way of doing things behind the scenes like creating reference variable to the form which is named from the “name” property of the form. thanks for that.

Leave a Reply

Your email address will not be published. Required fields are marked *