I have two controllers, one controller being for a form, which is called when the form's button is clicked, and one controller being for a div, which is interpollated using scope and {{}}. The problem is that I need to pass the data collected after the form is submitted to the other controller. How can I call that second controller's function within the first controller's function:
//FIRST CONTROLLER, CALLED BY CLICKING BUTTON
app.controller('FormController', function ($scope) {
$scope.IdSubmitted = function () {
$scope.datatokens = json_datatokens;
//WHERE I NEED TO CALL THE SECOND CONTROLLER, AND PASS IT "json_datatokens"
}
});
//SECOND CONTROLLER
app.controller('#10Controller', function ($scope) {
$scope.datatokens = json_datatokens;
});
HTML:
#FORM
<div ng-controller="FormController">
<form class="search-wrapper" onsubmit='load_button();fetch_data();return false;'>
<input type="text">
<button type="submit" class="button " ng-click="IdSubmitted()">Submit Info</button>
</form>
#DIV
<div ng-controller='#10Controller' ng-init="init()">
<p>Your payment is {{datatokens["DB.PMT"]}}</p>
</div>