javascript - nested controllers in angularjs -


we're pretty new this. after managing ui-bootstrap working date control :-

<div class="col-md-2 box" ng-controller="resultfilter" >   <h2>filter</h2>      <p class="input-group" ng-controller="datepickerdemoctrl">         <input type="text" class="form-control" datepicker-popup="{{format}}" ng-model="resultfilter.startdate" is-open="opened1" min="mindate" max="'2015-06-22'" datepicker-options="dateoptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="close" />         <span class="input-group-btn">         <button class="btn btn-default" ng-click="open($event, 'opened1')"><i class="glyphicon glyphicon-calendar"></i></button>         </span>     </p>    <p class="input-group" ng-controller="datepickerdemoctrl">         <input type="text" class="form-control" datepicker-popup="{{format}}" ng-model="resultfilter.enddate" is-open="opened2" min="mindate" max="'2015-06-22'" datepicker-options="dateoptions" date-disabled="disabled(date, mode)" ng-required="true" close-text="close" />         <span class="input-group-btn">         <button class="btn btn-default" ng-click="open($event, 'opened2')"><i class="glyphicon glyphicon-calendar"></i></button>         </span>     </p>  <p class="input-group">     <select class="form-control" ng-model="resultfilter.frequency">   <option value="daily">daily</option> <option value="weekly">weekly</option> <option value="monthly">monthly</option> <option value="yearly">yearly</option> </select>       </p> </div> 

we capturing click following angular

cisapp.controller('resultfilter', function resultfilter($scope, $http) { $scope.updateresults = function () {   }; }); 

how ever, how @ value of start date within controller of datepickerdemoctrl? following doesnt work?

$scope.resultfilter.startdate 

any appreciated

ng-controller creates new scope. both of datepickerdemoctrl child scopes of resultfilter. in case, try:

$scope.$$childhead.resultfilter.startdate 

this solution not recommended imo creates tightly coupled code, you're assuming there child scope controller, more recommended approaches:

  • use $on, $emit, $broadcast communicate between scopes.
  • create shared service hold state (i think not apply in case)

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -