Questions tagged [angularjs-controller]

The AngularJS controller exposes the data that is to be displayed into the HTML view. It plays the essential role of the ModelView in the MVVM design pattern. The view is a part of the HTML template.

AngularJS promotes the MVVM Design pattern.

The angularjs controller exposes the data that is to be displayed into the html view. It plays the essential role of the ModelView in the MVVM design pattern. The view is a part of the HTML template.

When a Controller is attached to the DOM via the ng-controller directive, Angular will instantiate a new Controller object, using the specified Controller's constructor function. A new child scope will be available as an injectable parameter to the Controller's constructor function as $scope.

ngController
The ngController directive attaches a controller class to the view. This is a key aspect of how angular supports the principles behind the Model-View-Controller design pattern.

Reference:
https://docs.angularjs.org/guide/controller
https://docs.angularjs.org/api/ng/directive/ngController

1243 questions
0
votes
2 answers

AngularJS - stops working when using controllers

So I'm just now starting to get into angularJS and things were fine with tests until I got into using controllers with ng-repeat. It seems that when I use it it just doesn't connect to the controller. I checked everything. The scope is fine and the…
0
votes
0 answers

AngularJS - Create a directive to fire an event (function) when the current element is appended to the DOM

I am trying to find a way to detect when an element is finally appended to DOM? Is there any directive that I can create and attach to that element so it will detect the moment of appending? By creating elements I mean ng-repeat, and onload and…
Georgi Angelov
  • 4,338
  • 12
  • 67
  • 96
0
votes
1 answer

Angular using another directive's controller?

If I have two directives, and need to have one of them use the controller of the other one, what is the best way to accomplish something like that in angular? I'm trying to use the require: otherDirective stuff I see in the docs, but I'm getting an…
reptilicus
  • 10,290
  • 6
  • 55
  • 79
0
votes
2 answers

Broadcasting across AngularJS controllers?

How do I broadcast a message between controllers? Here is what I have tried: function Ctrl1($scope) { $scope.$broadcast('Update'); } Ctrl1.$inject = ['$scope']; function Ctrl2($scope) { $scope.updated = false; $scope.$on('Update',…
0
votes
4 answers

Unable to share data between AngularJS controllers?

I had seen the egghead.io video on sharing data between controllers, but couldn't get it to work: var myApp = angular.module('myApp', []); myApp.factory('QData', function () { return 'hello' }); function QCtrl($scope, $http, QData) { …
0
votes
1 answer

Angularjs two separate ui elements communicating

I have a use case to toggle the view of a form using a button. The button is not nested in the same structure of the form, and is out side the scope of the forms controller. What is the best way to have this toggle button comunicate to the contents…
0
votes
1 answer

Controller doesn't work after URL change

In short: I have a controller that triggers some jQuery in my AngularJS web page to fade out a play button and a corresponding image. But, when the URL changes, the controller fails to work on subsequent pages. I'm using a dynamic URL, and I think…
0
votes
2 answers

Load-time exception handling in AngularJS

I need to execute a function which is defined in controller in load-time, in order to gain json data from another place right after page is loaded. I've tried to call the func immediately within controller, now i feel it was bad idea. When something…
VirtualVoid
  • 1,005
  • 3
  • 17
  • 25
0
votes
1 answer

Sharing a variable between controllers through a service

Here is my plunker: From what I understand, since the Service Variable being shared is an object, the object that gets loaded to the service by controller 1 should be plainly seen by controller2 without the need for $watches or listeners or…
JHixson
  • 1,512
  • 2
  • 14
  • 29
0
votes
1 answer

how to make child angular controllers in a page depends on main controller of page

In my webpage there is main controller that needs some initialization to be done using services by calling data from server using $http or getJSON. There are other child controllers in page that should not be called once main controller is done with…
user2025527
  • 109
  • 2
  • 12
-1
votes
1 answer

How to enable CORS in AngularJs?

I am trying to consume a ZOOM API POST method using angularJS: /webinars/{webinarId}/panelists When I run the solution locally, my angular controller, returns an error: Zoom provides the code to be implemented to be able to, through the end point,…
-1
votes
2 answers

Angular generated project, unresponsive controller

I'm sorry for the broad question but I'm having a hard time pin pointing my problem. I use the "ng new" command to generate a new angular project, but when i try to utilize controller in the project they remain unresponsive. To assure it was not my…
Alex Skotner
  • 462
  • 1
  • 8
  • 18
-1
votes
1 answer

AngularJS Unable to display upload file logs

I am trying to create a file upload function using angularjs which will just accept the file and send it to the server side (Django). To ensure the file upload function is working fine, I've placed multiple console.log in multiple locations.…
-1
votes
2 answers

How can I pull a specific title from an array using Angular?

I am trying to pull a specific title from an array using Angular. Whilst I can use ng-repeat to loop through all titles and print these to my news listing webpage, I only wish to pull the first heading in my array for the news details page. Do I…
Al-76
  • 1,738
  • 6
  • 22
  • 40
-1
votes
1 answer

Change the variable value in a service when logout is called

I have a device service and a device controller. First, time whenever the controller is called, I invoke setter method to set a boolean value. I want to change that value when the logout function is called which is in different service. My Device…
chan
  • 274
  • 1
  • 5
  • 24