var myApp = angular.module('myApp', []); myApp.controller('fooCtrl', ['$scope', '$injector', function ($scope, $injector) { $scope.serviceName = 'barService'; $scope.youAre = function () { $injector.get($scope.serviceName).myNameIs(); }; }]); myApp.service('barService', [function () { this.myNameIs = function () { alert('barService'); }; }]); myApp.service('bazService', [function () { this.myNameIs = function () { alert('bazService'); }; }]);
<div ng-app="myApp" ng-controller="fooCtrl"> <select ng-model="serviceName"> <option value="barService">barService</option> <option value="bazService">bazService</option> </select> <button ng-click="youAre()">You are ...</button> </div>