Questions tagged [angularjs-controlleras]

The Controller As syntax provides a way to access properties and methods of a controller declared on the controller via this. The controller instance is being published as the specified property on the scope.

"Controller As" syntax was introduced in AngularJS 1.2. Per AngularJS doc:

Using controller as makes it obvious which controller you are accessing in the template when multiple controllers apply to an element.

This does not replace $scope. If some specific bindings/watchers/broadcasts/etc are needed, the $scope could be injected into the controller and used as usual.

Some helpful readings:

112 questions
0
votes
1 answer

Shared scope of a directive when 'controller as' syntax is used

Here is a simple example of using directives (adapted from the official guide) - JSFiddle
angular.module('my-module', []) .controller('Controller', function($scope) { …
0
votes
2 answers

How to use controllerAs syntax with AngularJS modal in case of "modal in the same controller" approach

This is my modal function: vm.openUpdateStateModal = function (nextState, idea) { $scope.nextState = nextState; $scope.idea = idea; $scope.modalWindowOpen = true; $scope.modalInstance = $modal.open({ templateUrl: 'updateStateModal', …
akcasoy
  • 6,497
  • 13
  • 56
  • 100
0
votes
2 answers

why is this controller instantiated only once?

I have the following (also in Plunker):
0
votes
1 answer

this reference in callback with controllerAs-Syntax

I'm working on a angularjs project and I'm trying to implement it as close as possible to angularjs 2. In angularjs 2 there will be no more ng-controller and $scope, so I'm using directives instead of ng-controller. Also I'm trying to avoid the use…
Simon
  • 296
  • 4
  • 17
0
votes
1 answer

How to inject a controller as a dependency when using Controller As notation?

I have a controller that depends on another controller (for settings info). I'm trying to use the Controller As pattern but I get an injection error. Here's my controllers: angular.module('app2', []) .controller('ctrl1', [function () { var…
Jason
  • 2,455
  • 4
  • 37
  • 48
0
votes
1 answer

Angular Structure Incorrect Somewhere

All i am trying to do is call my back-end through an ng-Click and $http.get. I am then trying to set the value of the item i get to show up in my html. Here is my structure. Not really getting any errors so any information on how to see where my…
-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 2 3 4 5 6 7
8