Sean Sean - 29 days ago 12
AngularJS Question

Accessing a form in an Angular-UI uib-tab

If you have a form in a

uib-tab
, how do you access it to (eg) validate the form?

Here's a plunker: http://plnkr.co/edit/8hTccl5HAMJwUcHEtnLq?p=preview

When I try access
$scope.forminside
it's undefined (the form inside the uib-tab). But if I do the same with
$scope.formoutside
I get access to form validation etc.

Answer

The uib-tabset has its own scope, so the forminside will be on the scope of the uib-tabset. If you use the controller-as notation, it will find the correct scope (the one of the controller):

<uib-tab index="0" heading="Tab 1">
    <form name="vm.forminside">
    </form>
</uib-tab>

See this edited plunker.