The AngularJS 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.
Questions tagged [ng-controller]
186 questions
659
votes
15 answers
How to use a filter in a controller?
I have written a filter function which will return data based on the argument you are passing. I want the same functionality in my controller. Is it possible to reuse the filter function in a controller?
This is what I've tried so far:
function…

sumanth
- 6,593
- 3
- 13
- 7
157
votes
10 answers
Angularjs: 'controller as syntax' and $watch
How to subscribe on property change when using controller as syntax?
controller('TestCtrl', function ($scope) {
this.name = 'Max';
this.changeName = function () {
this.name = new Date();
}
// not working
…

Miron
- 2,137
- 3
- 15
- 14
117
votes
4 answers
AngularJS - convert dates in controller
Could anyone please suggest me how to convert date from this 1387843200000 format into this 24/12/2013 inside my controller?
Just FYI my dates are stored in this way & when binding to edit form with input type="date" field is not being populated at…

Iladarsda
- 10,640
- 39
- 106
- 170
101
votes
2 answers
Easiest way to pass an AngularJS scope variable from directive to controller?
What is the easiest way to pass an AngularJS scope variable from directive to controller? All of the examples that I've seen seem so complex, isn't there a way I can access a controller from a directive, and set one of it's scope variables?

winduptoy
- 5,366
- 11
- 49
- 67
17
votes
3 answers
How to instantiate ng-controller based on a condition
I asked this question but the specific question I'm asking has changed dramatically.
I have a piece of code:
This code is injected…
asdf

thank_you
- 11,001
- 19
- 101
- 185
7
votes
2 answers
AngularJS controller for a tab
I have three tabs in my page. I'm using tabset and tab according to Angular Bootstrap Docs.
I set a controller for the
which has the tabsetas

Nikhil
- 6,493
- 10
- 31
- 68
7
votes
2 answers
How to refactor angularjs controllers with mostly common code
I'm relatively new to angularjs. I've got some code (HTML + JS) that allows a user to add and remove entries from an in-scope array. Right now however I am massively repeating code for different arrays. I know this can be re-factored but I'm not…

axzr
- 660
- 5
- 16
6
votes
2 answers
Assign controller to element dynamically after bootstrap
I have an AngularJS app that I manually bootstrap at time 't'. At time 't + 1', I would like to show an HTML element that has no ng-controller attached. I would like to dynamically add a ng-controller to this element so it can communicate with my…

Nate
- 7,606
- 23
- 72
- 124
6
votes
3 answers
AngularJS beginner: ng-controller not working
I'm just trying to get my head around the basics of AngularJS. I tried writing a simple MVC app, but the controller doesn't seem to be working. The file can find the angular lib just find, I already tested that by excluding 'ng-controller'.…

BrianRT
- 1,952
- 5
- 18
- 27
5
votes
1 answer
Setting ng-controller dynamically from a variable value
I am developing an application using angularJs and nodejs. Am struck at setting the name of the controller to the value of a variable from main controller. To explain it better, my index.html looks like this :

Nagireddy Hanisha
- 1,290
- 4
- 17
- 39
4
votes
3 answers
AngularJS How to access parameter of one ngController in another ngController
Here is the thing:
For some reason I can't access controller1.Data.someId in the…
{{something}}

Jozef Kétyi
- 147
- 2
- 11
4
votes
3 answers
Angularjs: use config only for one controller
On one page I load content via ajax according to user picks (filters), to ensure that loaded content stays in place if user reloads or lands on the page, I put the picked filters into the url query string. Since I load the content via ajax on this…

qwaz
- 1,285
- 4
- 23
- 47
4
votes
1 answer
How to share $scope between controllers with AngularJs can we access to one controller’s $scope from another controller?
can we access to one controller’s $scope from another controller?
I need to get the entire data in parent,child and grandchild controller is it possible
Here is my script
var app = angular.module('myApp',…

Symon Kt
- 69
- 2
- 4
4
votes
1 answer
Send value as argument to a dynamically assigned controller
I'm trying to reproduce the modal view of AngularUI and dialog view of angular material behavior of assigning a controller dynamically and be able to send values as arguments
I tried to mimic AngularUI code without success:
var elem = …

Nate
- 7,606
- 23
- 72
- 124
4
votes
1 answer
Displaying Data after Time Interval in AngularJS
Here is the Link for the jsFiddle : AngularJS : Display Data
I have HTML File is like following:
Controller under .js…
{{test.testName}}

Vaibhav Jain
- 3,729
- 3
- 25
- 42