The angularjs-controlleras tag has no usage guidance, but it has a tag wiki.
1
vote
3answers
36 views
Is there really no difference between AngularJS $scope and Controller as syntax?
I am learning angularJS and while learning found the controller as syntax much easier to read and a little easier for me coming from the OO world to understand. I have read several articles and SO ...
0
votes
1answer
23 views
Angular controller functions are both constructors and a decorators?
If one writes a controller as ctrl for the following code:
function Controller($scope) {
$scope.abc = "123";
}
angularApp.controller("controller", Controller);
Does the pseudo code below ...
0
votes
1answer
24 views
Extend Angular controllers using controllerAs syntax & prototypical inheritance
I'm trying to extend controllers using conrollerAs syntax.
My parent and child controllers are not defined in the same scope, so I put the parent controller (BaseController) in a service:
...
1
vote
1answer
22 views
Issues unit testing controllerAs: logging controller returns a promise
I'm trying to test a controller which uses the controllerAs syntax. My problem is that when I try to test a function on the controller, I get "Expected undefined to be defined."
Controller ...
2
votes
0answers
87 views
AngularJs: this instead of $scope: TypeError: this.* is not a function at *
I'm stuck with an issue when try to implement registering function for a web.
Honestly, i just read some document about angularJs (and little bit about javascript) yesterday + under push. So, do not ...
0
votes
1answer
35 views
How to use a controllerAs syntax within a directive template in AngularJS
Here is my controller:
angular
.module('app')
.controller('MyCtrl', MyCtrl);
Viewer.$inject = [];
function MyCtrl() {
var vm = this;
vm.titles = ['Hello', 'world'];
}
My Directive:
...
1
vote
0answers
30 views
Passing ngModel to directive in controllerAs component
From a directive using the controllerAs declaration, I want to pass a scope variable to a nested directive, that is to be used within. I want any changes from "inside" to be reflected on the outside, ...
2
votes
2answers
49 views
angular “controller as syntax” “this” data
I dont understand what I am missing
I dont get result on html i think this problem managing with controllerAs syntax
note: I can see the result in console console.log(this.movie); - its from ...
0
votes
3answers
55 views
How to watch this variable in angularjs
I couldn't figure out how to watch a variable that binded to this variable in angularjs.
Here is what I have tried.
in html,
<input type="text" ng-model="vm.text"/>--{{vm.text}}--
...
3
votes
1answer
73 views
Trouble with Angular Nested Directives when using ControllerAs
I am building a huge form that calls various directives to build a complete form. The Main Page calling the Form Builder passes the ng-model data like this:
<div form-builder ...
0
votes
2answers
29 views
Initializing angular controller variables
I am having an issue where my controller variables are not being initialized correctly as per the controller code.
The controller code is
angular.module('test')
.controller('RegisterCtrl', ...
0
votes
1answer
45 views
Angular with ES6 Controller As Behaving Strangely
That's a bad title. I'm aware. That's because I'm not entirely sure how to ask this question. I've got two essentially identical classes, behaving just a little bit differently, a corresponding ...
1
vote
1answer
77 views
AngularJS controllerAs: updating controller field in $interval does not update ng-show
I'm using the controllerAs syntax, and for some reason, when updating a controller's field in an $interval, it doesn't show/hide elements in the view properly. I use angular's UI router.
The issue ...
0
votes
0answers
51 views
Argument 'ClockOnController' is not a function, got undefined
Hi I've been having some problems refactoring my controllers into their own snippets
I want the controllers to inherit the dependencies from my initial app declaration.
"use strict";
...
0
votes
2answers
42 views
Using controller as syntax only updates one of the scopes
I'm a bit confused when it comes to the controller as syntax as I've never worked with it before. I'd like to know the correct way to fix this. Haven't been able to find a similar problem when ...
0
votes
1answer
52 views
Mixing ControllerAS with $scope
For all new work I use the ControllerAs syntax so that I can refer to the controller as vm within my views. Which is great.
However I still a large portion of old code that uses the $scope syntax. ...
5
votes
4answers
11k views
Calling directives methods from parent controller in AngularJS
I am using AngularJS with the alias controllers pattern. I can't access (or I don't know how to) directive methods from a parent controller.
I have a function inside my controller that should call a ...
0
votes
1answer
98 views
Angular and ngDialog issue where data is not showing though dialog is shown correctly
I am using Angular / Typescript with ng-Dialog. In this stage the ng-Dialog is showing the template correctly the way I want it. However, no data is shown. The scenario is this: I have a detail page ...
1
vote
2answers
58 views
What is the issue with this sample code in Angular Js
I am learning angularJS. I have tried a calculator using angularJS. Two combo boxes having inputs and the other combo box is having the operations. When the user clicks the button then it has to show ...
0
votes
1answer
75 views
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
<div ng-controller="Controller">
<my-customer></my-customer>
</div>
...
1
vote
3answers
68 views
Ng-Click not firing
whenever I click my submit button nothing happens, currently all I want it to do is print out the username and password to test there bindings.
And I am able to talk to the controller and print out ...
0
votes
2answers
51 views
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 = ...
0
votes
2answers
29 views
why is this controller instantiated only once?
I have the following (also in Plunker):
<!doctype html>
<html
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
...
2
votes
2answers
116 views
Using this instead of $scope inside controller
I am trying to follow style guide for angular and there wrote we should use this insted scope...
Styleguide
Could someone explain me when I am able to use this?
Here is my try..... What I am doing ...
1
vote
1answer
62 views
Import JSON data for AngularJS Web App
I have been following the Angular tutorials, and I am trying to get my JSON data to appear, yet I know I am doing something wrong, but can't figure out the proper method.
I know that somewhere in my ...
0
votes
0answers
34 views
How to unit test variables on the parent scope when using controllerAs syntax in Angular?
I'm trying to unit test a controller in which I'm using Angular's controllerAs syntax. I also use this to access variables in the parent scope. For example, if the parent controller is called parent, ...
4
votes
2answers
129 views
How to remove Cordova specific events outside Angular controller?
Imagine I have a controller which handles, for example, view changes:
function Controller($scope){
var viewModel = this;
viewModel.goBack= function(){
viewModel.visible = ...
2
votes
1answer
106 views
ng-show angular tab with ng-repeat
I have been working on this for a while now and cannot figure out why it will not work. This is the effect I am trying to create- http://plnkr.co/edit/RAeIwFbn2Zoe9WfLdMX8?p=preview. I wish to have ...
1
vote
1answer
64 views
AngularJS ng-click function not reached
When I'm adding new product to a product list its not working. So the products get loaded well but the ng-click function does not getting called. (The alert I put in the addProduct function is not ...
2
votes
2answers
117 views
AngularJS ControllerAs syntax and controller injected variables
I'm writing a directive and trying to stick to the John Papa style guide. So I've also decided to jump on the ControllerAs syntax wagon and I've got a tiny directive like below:
(function() {
...
1
vote
1answer
70 views
Binding with service variable using ControllerAs syntax without $scope?
I'm familiarizing myself with controllerAs syntax in AngularJS, and I've come to a problem when I need to do a simple binding to a service variable. Typically a $scope.$watch or $scope.$on would do, ...
1
vote
2answers
1k views
Using ControllerAs with a Directive
I'm trying to follow John Papa's angularJS style guide here and have started switching my directives to using controllerAs. However, this is not working. My template cannot seem to access anything ...
0
votes
3answers
396 views
Using ngRoute with 'controller as' syntax in angularJS
I have the following config and controllers
.config(function($routeProvider){
$routeProvider
.when('/', {
templateUrl: 'page-home.html',
controller: ...
1
vote
0answers
168 views
Angularjs - Access parent controller without using $scope and using controllerAs
I needed a way to access the parent scope of a controller without having to inject $scope to do so. The reason behind this is that I'm building a SPA and I wanted to apply a class to the body element ...
1
vote
1answer
317 views
Angular: directive with bindToController 'loses' data
I have actionButtons directive:
function actionButtons(){
'use strict';
return {
scope: {},
restrict: 'AE',
bindToController: {
itemId: '@',
...
0
votes
1answer
103 views
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 ...
7
votes
2answers
355 views
Why can't I overwrite the value of a variable like this?
I'm trying to figure out why I'm having trouble overwriting a value passed to an angularJS directive via an isolate scope (@). I try to overwrite the value of vm.index with the following:
vm.index = ...
0
votes
0answers
47 views
Bind to ControllerAs Variables in Directives
Right, not an easy one to explain but I'll do my best.
I'm trying to make a directive that watches/uses data from an outer-directive (both currently elements).
If I don't use controllerAs syntax, ...
1
vote
1answer
925 views
Angular form validation using the controllerAs syntax
I am currently facing the following problem:
I would like to validate my form input using the Angular ngModel directives.
When using those together with $scope they work fine.
Now, working with the ...
0
votes
1answer
46 views
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', ...
2
votes
1answer
69 views
Using ng-options for select when using as notation for controller
I have a select using ng-options to define the options which works fine when I use just the controller name within the ng-controller directive. The problem is that when I add "as options" to the ...
1
vote
1answer
79 views
Using controller inside another controller in AngularJS
Why I can't bind to controller's variable inside second controller?
<div ng-app="ManagerApp">
<div ng-controller="MainCtrl">
Main:
<div ng-repeat="state in ...
2
votes
2answers
141 views
Angular tab selecting using controller method
I am trying to use AngularJS to display the tab number when certain tab is selected using the controller method. It does not as expected. Greatly appreciate your help on this one.
HTML
<body ...
0
votes
1answer
45 views
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 ...
1
vote
1answer
36 views
Binding issue in AngularJS
I am trying to bind from a http get request. The http get is returning true or false. I have tested the get and it is returning properly. When I run the code below, it shows the alert(1111) ...