Thanks for your reply.
I looked into this code, and been wondering if it fits my needs.
Here's a simplified example of what I have.
Notice that some of the services are dependent on scope variables to work.
How would you go about and use extend here? And is this "service dependency 
on scope" is a good practice?

var MyApp = angular.module('myapp', ['kendo.directives']);

MyApp.controller('controller1', ['$scope','serviceInput','service1','service2', 
function($scope, serviceInput, service1, service2){

    // here comes some logic for this scope which adds stuff to the scope, like 
certain controller related variables

    $scope.serviceInput = serviceInput($scope);
    $scope.service1 = service1;
    $scope.service2 = service2;
  }]);

  MyApp.controller('controller2', 
['$scope','serviceInput','service1','service2', function($scope, serviceInput, 
service1, service2){

    // here comes some logic for this scope which adds stuff to the scope, like 
certain controller related variables

    $scope.serviceInput = serviceInput($scope);
    $scope.service1 = service1;
    $scope.service2 = service2;
  }]);

  MyApp.service('serviceInput', function($scope){
    return {
      param1: $scope.someValue,
      param2: $scope.otherValue,
      param3: 'bindToSomething?'
    };

  });

  MyApp.service('service1', {
    param1: 'someValue',  
    param2: 'someOtherValue',
    param3: function(){return "someValue"}
  });

  MyApp.service('service2', {
    param1: 'someValue',  
    param2: 'someOtherValue',
    param3: function(){return "someValue"}
  });


On Thursday, March 13, 2014 8:20:24 AM UTC+2, Sander Elias wrote:
>
> Hi Yonatan,
>
> Use angular.extend.
> put all of your dependencies in an object like this:
>
> myStuff = { param1: service1,
>   param2: service2,
>   param3: service3,
>   param4: service4
> }
>
> then in your controller you can do:
>
>   angular.extend($scope, myStuff);
>
> and you are done.
>
> Regards
> Sander
>

-- 
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