21
votes
3answers
26k views

How do I use $rootScope in Angular to store variables?

How do I use $rootScope to store variables in a controller I want to later access in another controller? For example: angular.module('myApp').controller('myCtrl', function($scope) { var a = ...
1
vote
2answers
3k views

AngularJS: open a new browser window, yet still retain scope and controller, and services

I'm writing an angularJS app. In this particular controller, I open a new browser window through the $window.open service. But in the new window, all the $scope variables are lost. I tried to use ...
2
votes
1answer
2k views

How to access the $ngModelController from inside the Controller without a Form and without a Directive

Maybe it's a rookie mistake, but I can't seem to access the $scope.model's $ngModelController so I can grab the $viewValue from it. I have an input without a form (im using ui-mask directive): ...
0
votes
2answers
573 views

From an AngularJS controller, how do I resolve another controller function defined in the module?

Self explanatory fiddle: http://jsfiddle.net/5FG2n/6/ I need to dynamically choose the controller to use at runtime based on its name as a string. The string will be read from a config object. In ...
6
votes
1answer
3k views

Sharing data between AngularJS controllers? [duplicate]

How do I store the items I've selected in a checkbox with other controllers? My attempt (see the plnkr for views): script.js (controllers) var myApp = angular.module('myApp', []); ...
0
votes
3answers
2k views

$watch not working on variable from other controller?

I have one controller which displays a checklist, and stores the selection in an array. My other controller runs an $http.get on the array from the first controller. How do I set a $watch so that ...