Questions tagged [controlleras]

22 questions
5
votes
3 answers

ngrepeat alias as and controller as

I get this error https://code.angularjs.org/1.3.16/docs/error/ngRepeat/badident when I try to use ngRepeat alias as syntax with controller as syntax:
  • {{item}}
  • It's not…
    Ivan G
    • 404
    • 1
    • 4
    • 17
    4
    votes
    0 answers

    Using alias controller in templates to compile

    I'm unit testing a controller and I want to check whether the view is correctly updated. Some field of the view are related to fields/functions of the controller. When I try to get the compiled view, I'm not able to link the controller to the…
    Gaetano L
    • 85
    • 6
    4
    votes
    1 answer

    AngularJS 1.4: How to create two-way binding using bindToController and controllerAs syntax

    Okay, this is really bugging me. I have a directive with isolate scope, using the controllerAs syntax and bindToController: function exampleDirectiveFactory() { var bindings = { foo: '=', bar: '@' } return { …
    Shaun Scovil
    • 3,905
    • 5
    • 39
    • 58
    3
    votes
    1 answer

    how can I access ngModel from directive controller

    function prMySelects() { var ddo = { restrict: 'E', templateUrl: 'template.html', require: '?ngModel', scope: { ngModel: '=' }, controller: prMySelectsController, controllerAs: 'vm', bindToController: true …
    3
    votes
    2 answers

    angular controller as watch variable in parent controller

    how do i watch a variable, that is bind to a parent controller? function config($stateProvider) { $stateProvider .state('home', { url: '/', templateUrl: 'home.html', controller: 'HomeController', …
    user3532505
    • 429
    • 1
    • 7
    • 18
    3
    votes
    2 answers

    Where to place click handlers using controllerAs syntax in directives

    When using the controllerAs syntax in AngularJS, what is the best place to define handlers for ng-click and such? On the controller or on the scope (defined in the link function)? So, do you use: angular.module('app', []). …
    Bas Slagter
    • 9,831
    • 7
    • 47
    • 78
    2
    votes
    1 answer

    angularjs directive unit test fail with controllerAs, bindToController & isolateScope()

    I am trying to unit test a directive with a two-way bound property (=). The directive works in my app, but I can't get a unit test working that tests the two-way binding. I have been trying to get this working for days. I've read MANY examples that…
    2
    votes
    2 answers

    populate value of id attribute from controller in template angularJs

    I am writing a directive with angularJs, with a simple below html template and a contorller as c template:

    Input id : {{c.inputId()}}

    but the problem…
    Paridokht
    • 1,374
    • 6
    • 20
    • 45
    2
    votes
    3 answers

    How to use an isolated scope property properly?

    How to use an isolated scope property properly? I have a directive, that is called from a page controller, with an attribute item passed to it, e.g. , containing an id. The code below will not work, as it…
    Andreas
    • 1,211
    • 1
    • 10
    • 21
    1
    vote
    1 answer

    Access this of a controller when using controller as inside directive template

    How do i access This of controller inside of directive and its template when not using isoloted scope? app.controller('ChildCtrl', function() { this.name = "Name from children"; });
    Hacker
    • 7,798
    • 19
    • 84
    • 154
    1
    vote
    1 answer

    Angular ControllerAs syntax with custom directive

    Hello I have a problem in uploading an image .I use typescript so I tried to adapt a fiddle. I found on the internet but the problem is that I don't use the scope so the field 'myFile' is not being modified from the directive.I used the…
    jjijji
    • 89
    • 1
    • 9
    1
    vote
    0 answers

    (Angular) Passing instance of controller to isolate scope

    While the code below "works", it definitely feels very wrong. Is there a "best practices" way to refactor? The issue is that I'm passing an instance of the controller into an isolate scope directive (note: I can't use this in the…
    1
    vote
    1 answer

    best way to pass data from calling controller to ngDialog - check my code

    I am using ngDialog to show/update/delete detail records. The code that I have is working ok but I don't like the way to use the $scope like this.$scope.newContact = this.newContact; I would like to use controller or controllerAs syntax but cannot…
    user1829319
    • 691
    • 1
    • 8
    • 22
    1
    vote
    1 answer

    How to update another angular controller in real-time using controllerAs syntax

    I'm currently attempting to retrieve a row count value from a web API using a service from one controller, and then update a different controller's variable after the value has been retrieved from the DB - all while avoiding using $scope or…
    1
    vote
    0 answers

    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, and the child controller called child, then in…
    1
    2