angularjs - How to access a ngform name from controller? -


i need check if elements on current html page (being rendered using ui-view) dirty or pristine before navigate next tab.

parent page:

<div class="inner-menu">     <nav>       <div>         <ul class="nav nav-tabs edit-menu" role="tablist">           <!-- location 1 -->           <li ng-repeat="innertab in innertablistarr" ng-click="switchtab($index, $event)">             <a role="tab" data-toggle="tab" href="">{{innertab.text}}</a>           </li>         </ul>       </div>     </nav>     <div ui-view="innertabholder" name="currform"></div>         </div> 

and html template rendered innertabholder view :

<div class="edit-general" id="general">   <div class="modal-dialog modal-lg">     <form class="form-horizontal" name="generalform">         <label for="inputl3" class="control-label">text</label>         <div class="col-sm-4">           <input type="text" class="form-control" ng-model="gn.mymdl">         </div>         <div class="box-footer">            <div class="row">              <div class="col-sm-10">                   <!-- location 2 -->                   <button class="btn" type="button" ng-click="switchtab(generalform, $event)"> bck </button>                   <button class="btn" type="button" ng-click="savegen()">save above</button>                   <button class="btn" type="button" ng-click="switchtab(generalform, $event)"> fwd </button>               </div>             </div>          </div>     </form>                              </div> </div> 

there multiple tabs rendered view. , controller have:

myapp.controller('comptabctrl',[ '$rootscope', '$scope', '$state', 'mainwebservice', function($rootscope, $scope, $state, mainwebservice){    $scope.innertablistarr = [{"text" : "tab 1"},{"text" : "tab 2"}];    $scope.switchinnertab = function(tabid, event){    }; }]); 

ok, basic outline , believe, have covered parts. now, issue not able pass form : "generalform" switchtab function @ location 1 can same @ location 2.

i using form's $dirty , $pristine check if user has made changes form. so, while clicking on tab navigation, form becomes undefined.

how access $dirty property of sub-view in controller.

plunker demo :

https://plnkr.co/edit/06f5jfxltinyxrzbbc14?p=preview

when trying access variable use $scope

access curform using

$scope.curform.$dirty 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -