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
-1
votes
1 answer

Using directive way to build up a form with some input values

I am trying to get some input fields which collect the info after clicking the submit button using directive method and pass these values as arguments to a function. This is my code which doesn't work
-1
votes
2 answers

What is key benefits of using controllerAS in angularJS

ng-controller="invoiceController as invoice" create new invoiceController constructor and assigned the same to scope behind the scene, which the similar thing $scope injection does in controller function parameter am i right for the above point. if…
-1
votes
1 answer

How do I use this format of JSON in ng-repeat

This is the JSON and controllers im using: JSON Format: {"networks":[{"longName":"lo"},{"longName":"eth0"}]} Factory: app.factory('networkFactory', [ '$http', function($http) { …
-1
votes
2 answers

Setting the value of ng-click directive based on the variable assigned to it

I'm using angularJS to make a SAP. The problem I am having is within one of my template files. I want to set the value of ng-click directive using a variable declared in that controller. Based on the change in the value of that variable the value of…
-1
votes
1 answer

How to get Values from Other AngularJs Controller $scope variable

I'm having two controllers namely AController and BController. I need to get the value of Controller AController's $scope.myName to the Controller BController's $scope.myName. Note: Here I'm not passing the value, I'm trying to fetch the…
B.Balamanigandan
  • 4,713
  • 11
  • 68
  • 130
-1
votes
1 answer

Angularjs controller embed in a function

How about embedding angularjs controller in a function. So that we can initiate whenever we want. fucntion execute() { angular.controller('ProductsPageController', ['$scope', '$http', 'InitService', function ($scope, $http, InitService) { }) …
-1
votes
1 answer

Linking one controller to another to call service on ng-click

I have two templates with respective controllers and service files. One template's(fleetListTemplate) controller(fleetListController) loads data from its service file(fleetService) and displays in its view(fleetListTemplate). When this happens,…
-1
votes
2 answers

Error: [ng:areq] Argument 'ext-modules/fleet/jsFleetController.js' is not a function, got undefined

am getting "Error: [ng:areq] Argument 'ext-modules/fleet/jsFleetController.js' is not a function, got undefined" this error message when ever I load the template file. The following are the code, please can anyone say what is wrong in the code.…
-1
votes
1 answer

TypeError: value is undefined angularjs

I have a controller .controller('ArticlesCtrl', function($scope) { $scope.sum = function(value) { return value.reduce(function(total, article) { return total + article.price; }, 0); }; }); and json [ {"id": "1", "name":…
Vlad
  • 19
  • 2
-1
votes
1 answer

angular directive call to controller method with parameter

I have a controller with method that gets a parameter, and I want a directive to call that method and pass the parameter. how do I add a tag to the controller when a user clicks a tag inside the directive. a bit of code: app.controller('MainCtrl',…
-1
votes
1 answer

AngularJS $scope.$parent strange hierarchy

I'm trying to access the $parent in my child controller but for some reason I have to access the Fifth $parent in order to get the actual $scope from the Parent controller, Any Ideas? Parent…
Gabriel Matusevich
  • 3,835
  • 10
  • 39
  • 58
-1
votes
1 answer

How can you get Angular to regenerate parts of page after data is changed?

Simply put: My Angular app parses through a JSON object of objects of objects using ng-repeat and some ng-shows, etc. It makes a nice layout on the page with all the data. In my page, the JSON objects (at any level) can be updated by the user. The…
CodyBugstein
  • 21,984
  • 61
  • 207
  • 363
-1
votes
1 answer

Access angularjs controller from factory angularjs

We build a controller that holds all the $resource of our app for easier access from the controllers : app.controller('ResourcesCtrl', ['$scope', '$resource', '$controller', function ($scope, $resource, $controller) { $scope.Product =…
Shai M.
  • 1,284
  • 4
  • 17
  • 30
-1
votes
1 answer

Confusion about data usage in Controllers

How can I use the fetched data in customersController in AnotherCustomersController function customersController($scope, $http) { $http.get("http://www.w3schools.com//website/Customers_JSON.php") .success(function(response) {$scope.names =…
Learner
  • 13
  • 1
-1
votes
1 answer

How to use a function defined in a controller in another controller in angularjs

I have 2 controllers, loginCtrl and regCtrl, there is a function inside the login controller $scope.login and i want to call this function from inside my regCtrl. What i am trying to achieve is to redirect an user to his homepage without need for…
1 2 3
82
83