I'm currently using the following.
$scope.$$childHead.customerForm[firstName]
, so that:
<form name="customerForm">
<input type="text" name="firstName"
ng-model="data.customer.firstName"
tabindex="1"
ng-disabled="!data.editable"
validationcustomer />
</form>
But this only works in Chrome. Now I tried the following:
$scope.editCustomerForm[firstName]
, so that:
<form name="customerForm" ng-model="editCustomerForm">
<input type="text" name="firstName"
ng-model="data.customer.firstName" tabindex="1"
ng-disabled="!data.editable"
validationcustomer />
</form>
Which doesn't work. Note my form is inside a Foundation Tab. How can I access firstName
?
EDIT: It looks like the form
isn't added to the scope
when it's inside a Foundation Tab.
Anyone has got a solution for this?
You can attach the form to some object which is defined in a parent controller. Then you can reach your form even from a child scope.
Parent controller
Some template in a child scope
Problem is that the form doesn't have to be defined in the moment when to code in the controller is executed. So you have to do something like this
To be able to access the form in your controller, you have to add it to a dummy scope object.
Something like
$scope.dummy = {}
For your situation this would mean something like:
In your controller you will be able to access the form by:
and you will be able to do stuff like
WIKI LINK
This answer is a little late, but I stumbled upon a solution that makes everything a LOT easier.
You can actually assign the form name directly to your controller if you're using the controllerAs syntax and then reference it from your "this" variable. Here's how I did it in my code:
I configured the controller via ui-router (but you can do it however you want, even in the HTML directly with something like
<div ng-controller="someController as myCtrl">
) This is what it might look like in a ui-router configuration:and then in the HTML, you just set the form name as the "controllerAs"."name" like so:
now inside your controller you can very simply do this:
Bit late for an answer but came with following option. It is working for me but not sure if it is the correct way or not.
In my view I'm doing this:
And in the controller:
Now after doing this I have got my form in my controller variable which is
$scope.myForm