angularjs - How can I communicate the state of a data area's pristine state to my scope? -


i have following:

    <div data-ng-controller="admingridcontentcontroller" >         <ng-include src="'/content/app/admin/partials/grid-content-base.html'"></ng-include>         <ng-include src="'/content/app/admin/partials/table-content.html'"></ng-include>     </div> 

my table include looks this:

<div ng-form name="page">     {{ page.$pristine }}     <table width="100%" cellspacing="0" class="form table" >             <tr>                 <th>id</th>                 <th>title</th>              </tr>             <tr data-ng-repeat="row in grid.data">                 <td>{{ row.contentid }}</td>                 <td><input type="text" ng-model="row.title" /></td>             </tr>     </table> </div> 

what put button on grid-content-base enabled when data on table becomes dirty. know can check state of data {{ page.$pristine }} how can communicate grid-content-base.html?

note did try put inside "ng-form name=page" there's problem. on grid-content-base have input select. select makes page show dirty.

so still want set globally when page.$pristine becomes true or false.

there option $rootscope.$broadcast , send message table page. can handled in grid page.

something in table controller

$scope.$watch('page.$pristine',function(newvalue) {     $rootscope.broadcast("formupdated",{state:page.$pristine}); }); 

and in grid controller

$scope.on("formupdated",function(args) {     //args.state have state. }); 

note:$rootscope has injected controller inject $scope


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -