I want to access the value of the model date from another controller, and make a request passing this value in a json object. But this ng-model is in the scope of the controller DateParseCtrl and this controller is inside another controller called mainController. How can I access this value and pass to a json object from mainController? Ps: I just want get date value from mainController.
index.html
<body ng-controller='mainController'>
<datepicker date-format="dd/MM/yyyy" selector="form-control"
ng-controller='DateParserController'>
<input type="text" uib-datepicker-popup="{{ format }}"
ng-model='date' ng-blur='getSomething()'/>
</datepicker>
</body>
date-parse-ctrl.js
angular.module('myApp')
.controller('DateParserCtrl', function($scope, uibDateParser){
$scope.format = 'dd/MM/yyyy';
$scope.date = new Date();
});
mainController
angular.module('myApp')
.controller('mainController', function($scope, $http){
var date = $scope.date;
$scope.getSomething = function(){
$http({
method: 'POST',
url: 'url',
data: {date: date}
})
}
});