I saw a lot of questions related to this question, but no solution I tried works:
Inside the public folder, I have a file called app.js, where I define my AngularJS application as follows:
var app = angular.module('app', []); var RectangleDim=30; app.controller('MainCtrl', function($scope, $http) {
And at the end of the file, I do bootstrap as:
angular.bootstrap(document.getElementById('body'), ["app"]);
Then, inside the same folder and inside HTML, my entry point for an AngularJS application is as follows:
<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;">
Then in another folder I have another JS file where I need to call a specific function defined in AngularJS code. The function is called Draw (), and it fires when I click the AngularJS button.
To just call a function inside another file without clicking on any button, I do something like this:
var e = document.getElementById('body'); var scope = angular.element(e).scope();
EDIT: To make my question more understandable, I can add a few details:
I need only one controller and one module that controls my entire application, because all the necessary actions (which call 3 functions that update the SVG image) are relatively autonomous, so I donβt think there is any need to add complexity to the client code that can only confuse me and other people working with me.
To remember what I need:
Inside a single application with one controller, I have one Draw (someInputValue) function that generates an SVG digit. The input for this function is taken from the input text box.
In another file, I have JS actions that are executed when I click on another text field (for example, show a warning or create an additional text field). I want to bind a Draw call (input) when I click on a text box.
Namely, I want to simulate the behavior that I have when I click on a button that reads a number from a text field and performs some actions, but instead has input manually entered into the text field and clicking on the button, I just want to click on the text field and perform the same action.