I'm still struggling to make it work that way :(

Here is my sample code:
---------------------------------------------------------------------------------------------------------------------
'use strict';

myApp.controller('First', ['$scope', 'Users', 'Assign', function($scope, 
Users, Assign){
        Users.users(function(results){
            $scope.users = results;
        });

    $scope.fn = function(id, n1){
        $scope.n1 = n1;
        $scope.id = id;
    }

    $scope.ln = function(){
        Assign.assign(function(results){
            $scope.work = results;
        });
    }
}]).controller('Second', ['$scope', 'Users', 'Lang', function($scope, 
Users, Lang){
        Lang.langs(function(results){
            $scope.lang    = results;   
        });
        Users.users(function(results){
            $scope.users = results;
        });
    
    $scope.fn = function(id, n1){
        $scope.n1 = n1;
        $scope.id = id;
    }
}]);

---------------------------------------------------------------------------------------------------------------------



I changed above code to:

---------------------------------------------------------------------------------------------------------------------

(function() {


'use strict';

myApp.controller('First', ['$scope', 'Assign', function($scope, Assign, 
separate){
       
    $scope.ln = function(){
        Assign.assign(function(results){
            $scope.work = results;
        });
    }
}]).controller('Second', ['$scope', 'Lang', function($scope,Lang, separate){
        Lang.langs(function(results){
            $scope.lang    = results;   
        });
}]);

function separate($scope) {
     Users.users(function(results){
            $scope.users = results;
        });

    $scope.fn = function(id, n1){
        $scope.n1 = n1;
        $scope.id = id;
    }

}


})();
---------------------------------------------------------------------------------------------------------------------

I got errors with above code. I played around to make global scope. 
assigning *this *variable to a local variable etc. But couldn't make it 
work.
Any input on solving above problem will be very helpful.

Thanks @Sander Elias and @Nicholas Smith

*[*Am reading style-guide and trying my best to understand it.*]*

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

Reply via email to