All Questions

807
votes
13answers
525151 views

Working with $scope.$emit and $scope.$on

How can I send my $scope object from one controller to another using .$emit and .$on methods? function firstCtrl($scope) { $scope.$emit('someEvent', [1,2,3]); } function secondCtrl($scope) { ...
451
votes
19answers
189244 views

What's the correct way to communicate between controllers in AngularJS?

What's the correct way to communicate between controllers? I'm currently using a horrible fudge involving window: function StockSubgroupCtrl($scope, $http) { $scope.subgroups = []; $scope.ha...
260
votes
26answers
607089 views

File Upload using AngularJS

Here is my HTML form: <form name="myForm" ng-submit=""> <input ng-model='file' type="file"/> <input type="submit" value='Submit'/> </form> I want to upload an image ...
223
votes
18answers
308373 views

Passing data between controllers in Angular JS?

I have a basic controller that displays my products, App.controller('ProductCtrl',function($scope,$productFactory){ $productFactory.get().success(function(data){ $scope.products = dat...
942
votes
7answers
791778 views

How do I use $scope.$watch and $scope.$apply in AngularJS?

I don't understand how to use $scope.$watch and $scope.$apply. The official documentation isn't helpful. What I don't understand specifically: Are they connected to the DOM? How can I update DOM ch...
745
votes
23answers
369522 views

AngularJS : Prevent error $digest already in progress when calling $scope.$apply()

I'm finding that I need to update my page to my scope manually more and more since building an application in angular. The only way I know of to do this is to call $apply() from the scope of my contr...
117
votes
12answers
105760 views

Controller not a function, got undefined, while defining controllers globally

I am writing a sample application using angularjs. i got an error mentioned below on chrome browser. Error is Error: [ng:areq] http://errors.angularjs.org/1.3.0-beta.17/ng/areq?p0=ContactControl...
683
votes
31answers
487560 views

How to set focus on input field?

What is the 'Angular way' to set focus on input field in AngularJS? More specific requirements: When a Modal is opened, set focus on a predefined <input> inside this Modal. Everytime <inpu...
250
votes
11answers
238273 views

ng-model for <input type="file"/>

I tried to use ng-model on input tag with type file: <input type="file" ng-model="vm.uploadme" /> But after selecting a file, in controller, $scope.vm.uploadme is still undefined. How do I g...
312
votes
15answers
297597 views

AngularJS: How can I pass variables between controllers?

I have two Angular controllers: function Ctrl1($scope) { $scope.prop1 = "First"; } function Ctrl2($scope) { $scope.prop2 = "Second"; $scope.both = Ctrl1.prop1 + $scope.prop2; //This is w...

Previous Next