I have come across numerous inquiries regarding this issue, yet none of the solutions I've attempted have been effective:
Within the public folder, there is a file named app.js where I define my AngularJS application as follows:
var app = angular.module('app', []);
var RectangleDim=30;
app.controller('MainCtrl', function($scope, $http) {
At the end of the file, I perform the bootstrap like so:
angular.bootstrap(document.getElementById('body'), ["app"]);
Then, within the same folder and inside the HTML, the entry point for the AngularJS application appears as:
<div id="body">
<div ng-controller="MainCtrl">
<div class="col-sm-6 col-md-6 col-lg-6" style="background-color: #D2D7D3">
<div style="padding:25px;">
In another directory, I have a different JS file where I need to call a specific function defined in the AngularJS code. This function, Draw(), is triggered when an AngularJS button is clicked.
To simply invoke the function from another file without clicking on any button, I am implementing something similar to this:
var e = document.getElementById('body');
var scope = angular.element(e).scope();
// update the model with a wrap in $apply(fn) which will refresh the view for us
scope.$apply(function() {
scope.Draw(NumQuest);
});
//fim
EDIT: To clarify my question further, here are some additional details:
I only require one controller and a single module to manage my entire application because all necessary actions (which involve calling 3 functions that update an SVG image) are fairly self-contained. Therefore, adding complexity to the client-side code would likely lead to confusion for myself and other collaborators.
To reiterate what I need:
Within a single app, utilizing one controller, I possess a function, Draw(someInputValue), that creates an SVG image. The input for this function is derived from a text input box.
In another file, I have JavaScript actions executed upon clicking another text box (e.g., displaying an alert or generating an additional text box). My objective is to link a call to Draw(input) upon clicking the text box.
In essence, my goal is to replicate the behavior observed when a button is clicked to read a number from a text box and execute certain actions. Instead of manually entering the input in a text box and clicking a button, I aim to simply click on a text box to achieve the same outcome.