I am using Angular 1.5.7 version.

I have a directive that takes in the controller name and view name as 
strings to then invoke the controller respectively.

I am not able to bind username to the invoking controller from the previous 
controller, I see the value available in my previous controller (i am able 
to print the value).

Please can you advise what could be the issue?


I have tried setting the username inside the scope as well without the 
bindToController construct, but that still does not pass in username to the 
second controller.


In the first controller username is available as a resolved variable. I 
also tried setting it to vm.username = username (as below) in the first 
controller but that was not of much help either.


FIRST CONTROLLER 

angular
    .module('refdata.legalentity')
    .controller('PendingRequestsController', PendingRequestsController);

PendingRequestsController.$inject = ['username'];

function PendingRequestsController(username) {
    var vm = this;
    vm.username = username;



DIRECTIVE, where in I pass the second controller and view by name

myApp.directive("pendingRequests", function() {
    return {
        restrict: 'E',
        controller: "@",
        name: "controllerName",
        controllerAs: 'pendingReqCtrl',
        scope: {},
        bindToController: {
            username: '=username'
        },
        templateUrl: function(tElement, tAttrs) {
            return tAttrs.templateUrl;
        }
    };});

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to