I currently have a dashboard that has a variable x that is needed throughout my application. I have a factory in my dashboard.js that listens for x's value to change and updates it if needed. dashboard.js runs first and resolves x. There are several pages that have their own controllers that load after dashboard.js. These pages listen/use variable x. I am currently running Parse queries in the controllers of these pages however x is showing up as undefined so I cannot use it in my query. How do I run a controller only after x is defined?
Controller running Parse query before scope variable resolved
173 Views Asked by Niraj At
1
There are 1 best solutions below
Related Questions in ANGULARJS
- Angular Show All When No Filter Is Supplied
- Using pagination on a table in AngularJS
- State with different subviews
- Getting and passing MVC Model data to AngularJS controller
- Implementing prerender.io middleware in sails.js
- Token based authorization in nodejs/ExpressJs and Angular(Single Page Application)
- AngularJS, Google App Engine and URLrewrite
- send data from table to another page into forms
- How to write tests for classes with inheritance
- angularJS sending OPTIONS instead of POST
- Receiving POST from external application in AngularJS
- Metaprogramming AngularJS Filters
- Reload List after Closing Modal
- Why is my angularjs site not completely crawlable?
- Why is separation of JavaScript and HTML a good practice?
Related Questions in ANGULARJS-SCOPE
- how to show alert when user scroll to top of div in angular js?
- custom directive required params
- how to get event when user scroll to top in angular js?
- Access parent property from directive controller with ControllerAs syntax and no $scope injection
- AngularJS Material using $mdDialog in a directive linking function
- Passing data to newly created directive in angularjs when ajax call is over
- Can i send an object to isolated scope '@' property
- why array become blank after splitting into multiple small array?
- Directive with transclude, data binding not working in templateUrl
- Angular scope not affecting ng-show as expected
- auto-populate select list with a one to several relationship in AngularJS
- Angular-ui: Is any modal opened?
- AngularJS: Routes with Multiple resolves using Services are not firing
- AngularJS : Why the data is not displayed in view may I use $scope.apply?
- Can onbeforeunload event be watch by $watch in angular js?
Related Questions in ANGULARJS-CONTROLLER
- List dependencies injected
- angularjs TypeError: Cannot read property of undefined
- Unit testing controller triggering custom directive
- How to use Ionic Popup with scope in Controller As syntax?
- How to keep entered data of page1 after navigating back from page2 in AngularJS
- AngularJS : factory function undefined in controller
- What is the difference between these two angularjs controller definition
- Angular ui-router resolve value as string
- How can I add a directive from a module to a controller?
- Add new text box on click of a button in angular js
- angular directive call to controller method with parameter
- Angular JS controller
- Same "controller as" name in angular js directive breaks function in parent controller
- Angular Structure Incorrect Somewhere
- AngularJS: Cannot interpolate attribute from first directive to a second. (w/ plunker example)
Related Questions in ANGULARJS-FACTORY
- Angularjs error Unknown provider: $scopeProvider <- $scope <- user
- angularjs TypeError: Cannot read property of undefined
- AngularJS : factory function undefined in controller
- Angular - TypeError: XX is not a function
- Controller running Parse query before scope variable resolved
- How to make a service object that doesn't share its values with controllers that consume it
- Change in data made by $http inside a factory is not reflected to the DOM
- Parse query then state change after resolve
- Using factory service for resolve and to hold variable across controllers
- Unknown Provider error Angular
- Fetching data json with factory
- PassFactory.setNewPass is not a function, factory function not a function
- factory is unable to convey data to another controller
- Call FCM factory in a controller to get notification data
- Can't store data of a multi step form built using Angular.js UI Router
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Assuming the relationship between your controllers already is a parent-child relationship and your variable is declared on the $scope, your childcontrollers should normally inherit that variable. Without any code , its hard to tell.
Either way, you could use the $rootScope to make that variable accessible. Eventhough this is technically possible , this is generally not the way you want to do it.
Then you have to possibility to broadcast/emit and watch and event as X changes. You can also transmit data over an event. This is what you are already doing, I guess?
You could also create a service that is injected in every controller, regardless of their relation, that keeps track of your variable. Or in your case, you could assign that functionality to the factory too.
But it is hard to tell without any code what you're trying to do.