How to use two AngularJS services with same name from different modules? -
supposed have 2 modules angularjs, e.g. foo
, bar
, , both of them define service called baz
.
in application depend on them saying:
var app = angular.module('app', [ 'foo', 'bar' ]);
then can try use baz
service in controller using
app.controller('blacontroller', [ '$scope', 'baz', function($scope, baz) { // ... }]);
how can define of 2 services i'd use? there such fully-qualified name?
the service locator looks services name (angularjs guide di). "namespacing" services in angularjs:
as of today angularjs doesn't handle namespace collisions services if you've got 2 different modules service named same way , include both modules in app, 1 service available.
i guess can make qualified name "by hand": name service foo.baz
, bar.baz
instead of plain baz
. it's kind of self-delusion. moreover, writing way doesn't make namespacing real, person reads code might think so.
Comments
Post a Comment