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

AngularJS, ngResource, Service and multiple controllers. How to keep data synchronized?

I searched a lot about this, and although I found some similar problems, they are not exactly what I want. Imagine this kind of code: angular .module('foobar', ['ngResource']) .service('Brand', ['$resource', function($resource){ …
-1
votes
2 answers

Call directive API method from 'parent' controller in AngularJS

I have a situation where I want to create custom component, which should be reusable and provide public API to change it's state. I am trying to achieve this by building component using directive and controller. What I desire to do is…
-1
votes
2 answers

Controllers vs filters in angularjs

Both of them look like simple functions with the controllers having a scope with them. What exactly is the difference between them?
me_digvijay
  • 5,374
  • 9
  • 46
  • 83
-1
votes
1 answer

Angularjs HTML compilation in Controller

I am facing a small problem during the compilation of html code in angularjs. Here is the brief description of my problem : $scope.report= reportdata; reportdata is the html code that contains angularcontents like : {{name}} , {{firstname}}…
Nilesh Gajare
  • 6,302
  • 3
  • 42
  • 73
-1
votes
2 answers

Angularjs existing controller is undefined

I'm building little bit bigger aplication in angular and I have problem with only one controller, they are all same, but this one is always undefined. Module is loaded because otherwise angular will crash. My app structure looks like…
zajca
  • 2,288
  • 4
  • 30
  • 40
-1
votes
2 answers

angular JS service is null inside the controller

This is my first learning project for angular js. i have created a controller(EditEventsController) and a service(eventData). Code for the EditEventController is 'user strict' eventsApp.controller("EditEventController", function…
Parv Sharma
  • 12,581
  • 4
  • 48
  • 80
-2
votes
1 answer

How do I fetch json data in angularjs controller

https://jsonplaceholder.typicode.com/posts I have to fetch data from this link and display it in my browser. In Javascript I used to do it using XMLHttpRequest and then parse it using JSON.parse(response). Is there a way I can achieve something…
-2
votes
2 answers

Is angularJS's $http used in a push or pull manner?

I've never heard this question answered clearly- "Is angularJS's $http a push or pull mechanism?" Update: Due to the comment I've received, I've modified the question to make it clear that my question is not about what $http actually does via TCP.…
GreeneCreations
  • 1,072
  • 1
  • 9
  • 20
-2
votes
2 answers

Angular JS Shared functions between controllers

I have this code: http://jsbin.com/gazajunacu/1/edit?html,js,output angular.module('app', []) .service('greeting', function Greeting() { var greeting = this; greeting.message = 'Default 2'; …
uiuxhub
  • 1,209
  • 2
  • 14
  • 24
-2
votes
1 answer

AngularJS : injecting data from factory to controller

I trying to get some data and then pass it to the controller for further processing. I have setup a factory to get the data but having issues passing it to the controller and getting it working. Below is the case I'm working with. var app =…
-2
votes
1 answer

Angular custom directive: a strange error occurs when set controller attribute to `function(scope){}`

When I wrote a custom directive, a strange error blocks me. angular.module('app.directives', []) .directive('cyMenu', ['RecursionHelper', function(RecursionHelper) { function postLink(){}; return { restrict: 'E', templateUrl:…
-2
votes
1 answer

Avoid Hard Coding Controller name Angularjs

I am a beginner in angular..I have a requirement to avoid hard coding any names in the app.. I have used myapp.constant("constantName", { "name":"name1" }); to avoid hard coding html..I would also like to avoid hard coding controller names…
-2
votes
1 answer

AngularJS how to pass data from one controller to different directives

I am not sure whether I can do like this or there is a better way. I need someone to guide me. I created two template using directive (both directives in the same page). Let say directiveVideo for display videos directivePhoto for display…
vzhen
  • 11,137
  • 13
  • 56
  • 87
1 2 3
82
83