I have been trying to use this example, to call a function from one controller, to another controller. So far, none of my attempts have worked. I currently have a Modal View with buttons inside of it, within the controller ModalViewController. The html for this appears:
<script type="text/ng-template" id="renderedContent.html">
<div class="modal-header">
<h3>Detailed View</h3>
</div>
<div class="modal-body">
<ul>
<li ng-repeat="data in storage">
<button style="border-radius:5px;color:white;background-color:#777777;border:none;margin:1px;" ng-click="myFunction(data)">
<h5 style="font-size:10px;padding:0px;margin:0px;">{{data}}</h5>
</button>
</li>
</ul>
</div>
<div class="modal-footer">
<button class="btn btn-default" ng-click="cancel()">Close</button>
</div>
</script>
The method myFunction() should set a value in another controller's scope. In particular, I have an input field in the controller InputController, that is basically:
<input type="text" ng-model="inputText"></input>
I am trying to write a function such that I can have something like:
//in ModalViewController
$scope.myFunction = function(data){
// call InputController
// set InputController.inputText = data;
}
I do not fully understand the code in the given link entirely. How would I write this function so it does what I'm seeking to do?