简体   繁体   English

AngularJs ng-controller覆盖

[英]AngularJs ng-controller overrides

I am newbie with AngularJS, I really need some help here. 我是AngularJS的新手,我真的需要这里的帮助。

I have JSBIN working example that displays two charts with different data. 我有一个JSBIN工作示例,该示例显示两个具有不同数据的图表。

For each chart I have different ng-controller. 对于每个图表,我都有不同的ng-controller。 By issue is my select dropdown only works with <div ng-controller="first"> chart. 按问题,我的选择下拉列表仅适用于<div ng-controller="first">图表。

My goals is to update both charts with select dropdown menu. 我的目标是使用选择下拉菜单更新两个图表。

If you check clearly, The $scope.filterOptions which is used in dropdown is defined in first controller. 如果您检查清楚,则在第一个控制器中定义了下拉菜单中使用的$ scope.filterOptions It is available in second because it is nested controller 它是嵌套控制器,因此可在第二秒内使用

<select ng-model="selectedyear" ng-change="sampleDropDown()"> <option ng-repeat="year in filterOptions.stores | unique: 'year'"> {{ year.year }} </option> </select> <select ng-model="selectedyear" ng-change="sampleDropDown()"> <option ng-repeat="year in filterOptions.stores | unique: 'year'"> {{ year.year }} </option> </select>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM