0
別のコントローラのデータを別のコントローラで使用しようとしています。これを達成する最良の方法はどれですか?他の出力コントローラの入力コントローラからのデータを使用
私は、入力と出力のコントローラと自分の意見を持っている:
入力コントローラ:
AppControllers.controller('DateCtrl', [
'$scope','$http',
function($scope, $http){
$http.get('/dates').then(function(response){
$scope.years = response.data.years
$scope.months = []
for (var i = 0; i < 12; i++) {
$scope.months.push(response.data.months[i])
}
})
}
]);
入力ビュー:
<div class="input-dual" ng-controller="DateCtrl">
<div class="input-dual-inner">
<span>Datum polaska:</span>
<select ng-model="selectedYear" ng-options="year as year for year in years">
</select>
</div>
</div>
出力コントローラ:
AppControllers.controller('DataOutput', [
'$scope','$http',
function($scope, $http){
}
]);
出力が争います
<div ng-controller="DataOutput">
{{ selectedYear }}
</div>