@Calendee Yeah we kinda diverted there for a bit haha…
I believe the issue with the form not being visible is actually correct, and expected as well. When Angular creates the isolated scope for the directive, because it is using ng-transclude, it will actually create a new child scope for the transcluded content. This new scope does not prototypically inherit from it’s parent, thus it’s not available on $scope.
One way to get around this is to use $parent. This will tell Angular to look to the parent scope for the property userForm:
Well I’m lost too. You “used” to be able to access the form controller from the controller. However, I can’t get it to work at all anymore - even when using $parent.
@mhartington : Do you know of something that would cause this? Did AngularJS change to prevent it?
@mhartington You’ve removed the ng-controller. So, the problem is still how to access the Angular form controller from the actual view controller. It used to be possible. If I add ng-controller back to yours, it dies because “testForm” is not available on the scope of “MainCtrl”
Ah alright, so you’re trying to get the text thats inside lastName, correct? Yeah I’m not sure what the issue is. I gave it another try and was able to get this.
Thank you so much!
I was reading so much bullshit on this thread with people that didn’t even try to understand what was going on!
I was mad because I could not get the for to work without it been the first element of the page (which rarely is) and your post helped me, thanks man, thanks you a lot!
If you can’t find a nested form in your $scope, check @DiscGolfer17 answer Jan’14.
after more than 6 hours trying to figure out what was going on with my code, i casually printed my whole object (i had an object user with name and password in it but when i tried to catch the name it gave me this undefined error) and i had my name still undefined but my password returned its value… Idk if this can help ppl, but i went to check my input tag and the difference between the name input and password input was the type. I have no idea why but with the type=email we have the input undefined. Changed to type=text and yay it worked.