[英]nested controllers in angularjs
we're pretty new to this. 我们对此很陌生。 After finally managing to get ui-Bootstrap working with a date control :- 在最终设法使ui-Bootstrap与日期控件一起工作后:-
<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 are capturing the click with the following angular 我们以以下角度捕获点击
CISApp.controller('ResultFilter', function ResultFilter($scope, $http) {
$scope.updateResults = function () {
};
});
how ever, how do we get at value of start date as it is within the controller of DatePickerDemoCtrl? 但是,如何获得DatePickerDemoCtrl控制器中的开始日期值? The following doesnt work? 以下不起作用?
$scope.resultfilter.startdate
any help would be appreciated 任何帮助,将不胜感激
ng-controller
creates new scope. ng-controller
创建新作用域。 Both of your DatepickerDemoCtrl
are child scopes of ResultFilter
. 无论你的DatepickerDemoCtrl
是子作用域ResultFilter
。 In your case, You could try: 对于您的情况,您可以尝试:
$scope.$$childHead.resultfilter.startdate
This solution is not recommended IMO as it creates tightly coupled code , you're assuming that there is a child scope for this controller, some more recommended approaches: IMO不建议使用此解决方案,因为它会创建紧密耦合的代码 ,您假设此控制器有一个子作用域,还有一些建议的方法:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.