Troubleshooting: Stage element not being recognized by Angular and CreateJS

I'm currently working on an Angular view that inherits from an ng-view element.

Within the view file, there is a canvas that is controlled by a specific controller. My goal is to bring up a stage that allows me to add elements onto the canvas.

However, every time I try running the createJS.Stage function, the stage is created with everything being null and there are no bounds in place.

My assumption is that the element is not properly binding to the stage, but I'm unable to figure out the reason behind this issue.

index.html

<ng-view     style='height: 100%;'></ng-view>

template.html

<div class='middle' style="min-height:90%;height:90%">
<div class='col-lg-8'>
<canvas id="demoCanvas" class='col-lg-11' style='margin-top:10px'></canvas>
</div>
</div>

JS

 app.controller('taskController',function($scope,$location,$routeParams,dataFactory){
    var stage = new createjs.Stage("demoCanvas");
    console.log(stage.getBounds()); 
   //bounds turn up as null as well as style and any other function that I run
}

Answer №1

It seems like the issue lies in the timing of the DOM loading in relation to the AngularJS controller execution.

In order to ensure that the controller runs once the DOM is fully loaded, you can use the following method:

app.controller('taskController',function($scope,$location,$routeParams,dataFactory){
    $timeout(function(){
        visualInspectionHandler();
    });
    function visualInspectionHandler(){
          var stage = new createjs.Stage("demoCanvas");
          console.log(stage.getBounds()); 
    }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I am seeking to showcase an image in a window, and upon the image being clicked, execute the code in a separate window

I am looking to showcase the image provided below. <img src="http://gfx.myview.com/MyView/skins/livesample/image/livesample.gif" alt="" border="0"><a/> Once the image is clicked, I want it to execute the following code. How can I ensure that ...

"Hiding elements with display: none still occupies space on the

For some reason, my Pagination nav is set to display:none but causing an empty space where it shouldn't be. Even after trying overflow:hidden, visibility:none, height:0, the issue persists. I suspect it might have something to do with relative and ab ...

I am looking to trigger the change event from within the click event in Angular

My objective involves detecting when the cancel button is clicked while a file is being uploaded. I am trying to accomplish this by triggering the click event, then monitoring for the change event. If the change event occurs, the document will be uploaded. ...

How can you use Dart to uncover the content within an H1 element on an HTML webpage?

I'm currently self-teaching mobile development with Dart and Flutter, and my current project involves connecting a mobile app to a website. I want to extract the text from an H1 tag that is loaded through JavaScript on the website and display it in th ...

Determine if the server is operational using Microsoft Edge

To verify the status of my server, I have implemented the code below: <head> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script> function checkServerStatus() { var img = document. ...

Altering the status of a property in an object, at a specific position within a collection of objects, contained within another object?

Currently using React and having some trouble with the setState hook to update a value deep within an object structure ...

Identify compatibility with the background-attachment property set to fixed

I've been searching for an updated answer on this topic, but I couldn't find one so I wanted to confirm. My goal is to achieve a parallax effect using background-attachment: fixed, however I've noticed that it doesn't work on mobile ph ...

My website has a navbar button that is not directing to the intended section of the screen

I have created this HTML code for my Navbar buttons: <button class="navbar-toggle" data-toggle = "collapse" data-target=".navHeaderCollapse"> <span class="icon-bar"></span> <span class="icon-bar">< ...

The isolated scope object of the Directive has not been defined

I recently started learning AngularJS and I'm trying to figure out how to connect a directive's isolated scope with the ng-model of the view. The form should be considered valid when either both inputs are empty or both are filled with values. Ca ...

Sending multiple HTTP requests sequentially

I've been attempting to send a request object to a server repeatedly in a loop, aiming to execute the task 1000 times. The scenario is reminiscent of the movie Office Space, where a small sum is extracted from numerous bank accounts. Here's the ...

The console is showing messages before the task is completed

When using console.log to write detailed messages about the current task expected to be performed by Protractor, I noticed that these messages are appearing on the console before the actual task is executed in the browser. An example of this is: it(' ...

Storing complex data using AJAX and HTML techniques

Consider this scenario. I have a table (<table>) where users can input the time spent on a project in a specific week. For example: -------------------------------------- |Project ID: | Monday | Tuesday | ...| | 123 | 7:15 | 3:45 | ... ...

JavaScript Callback Functions are Unable to Execute WebSQL Transactions

Currently utilizing PhoneGap in combination with jQuery Mobile, my goal is to retrieve JSON data from a remote source and then populate a local WebSQL database with said information. Below is the JavaScript function for this task: function getLocations() ...

Guide to extracting the outcomes of a promise array and populating them into a new array using Protractor

I am facing a challenge with transferring data from an array of promises generated by the following code: element.all(by.repeater('unit in units')). It seems to be difficult for me to store this data into another array: element.all(by.repeater(& ...

Having trouble importing Bootstrap into Next.js? It seems like the issue may be related to the

I am currently facing an issue with importing bootstrap 5.3.2 (not react-bootstrap) into my NextJS 14.1.0 project that utilizes the new App Router. My goal is to strategically utilize individual Bootstrap components (not through data-attrs). I managed to ...

I'm having trouble getting the function inside onLoad to run in my Next.js project - can anyone help

While I was exploring nextjs.org and following the tutorial, I encountered an issue where the function inside onLoad wasn't executing. It's puzzling because there was no call made to that link in the networks tab of my browser's developer to ...

Changing the size of the Modal Panel in Ui Bootstrap for a customized look

Currently, I am in the process of developing an application that utilizes Ui bootstrap to seamlessly integrate various Bootstrap components with AngularJs. One of the key features I require is a modal panel, however, I found that the default size option &a ...

"Steps for implementing a multiselect feature with checkboxes, including the ability to check all and uncheck all, in a React application

After creating a custom component for selecting multiple options and adding a check all feature, the challenge arises when needing an uncheck option. Solution? Implementing an uncheck all feature alongside the select all functionality, but how to modify th ...

My goal is to populate all of these elements with Javascript

My goal is to have all the boxes filled with "excellent": https://i.sstatic.net/oHW6W.png let a = document.querySelectorAll('.select2-choice'); a.forEach((e) => {console.log(e)}) a.forEach((e) => {e.innerHTML = ` <span ...

I'm curious as to why styled components weren't working before

I'm attempting to utilize the before on styled components in React, but it doesn't seem to be functioning correctly. Prior to adding before, the background image was displayed, but after its inclusion, the image is no longer showing up; import st ...