0

I want to make several controllers which has same logic. Only different parts are injections.

I can create controllers like this:

var controllerFunc = function($scope, service) {
    $scope.service = service;
}

app.controller('Controller1', ['$scope', 'Service1', controllerFunc]);
app.controller('Controller2', ['$scope', 'Service2', controllerFunc]);

But, it doesn't look like a AngularJS way. Are there any better ways? Or is it just good?

1 Answer 1

1

There's nothing about your code that's "not Angular-y". Just because you haven't seen it done before doesn't mean there's anything wrong with it.

I actually have written some code like that in my projects.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.