question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dot notated namespacing

See original GitHub issue

It would

Let’s say I have a simple API called:

var app = angular.module('slots', []);
app.service('slots.api', function() {
   return {
      get : function() {
         return true;
      }
   }
});

I use ng-annotate in conjunction with gulp to automatically include my dependencies for minification.

However, I have recently changed the way I namespace my modules, so If I have a service that’s specifically relating to the the slots module, I’ll prefix it with slots.

However ng-annotate doesn’t look like it supports that, is there a way to automatically do this with ng-annotate? so that the result would look something like:

app.service(['slots.api', function(api) {
    var result = api.get();
}]);

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
samithafcommented, Feb 23, 2016

@olov This seems to be a valid use case. If anyone is using ng-annotate in a large Angular App they going to hit this problem.

0reactions
deltaideacommented, May 13, 2016

Perhaps, support for such cases can be achieved by adding some sort of aliasing syntax.

  • The issue here is that if I have a service slots.api, that’s not a valid JS identifier and can’t be used as an argument name. You can’t write function(slots.api) { ... }.
  • Just using api as the argument name isn’t gonna work either. If I want two dependencies foo.api and bar.api, which one should be referred to as api? What about the other one?

How about this?

// Source
angular.module('foo').service(function (api /*ng-from slots*/) {})

// Translates to
angular.module('foo').service(['slots.api', function (api) {}])

Or this:

// Source
angular.module('foo').service(function (/*ng-as slots.api*/ api) {})

// Translates to the same
angular.module('foo').service(['slots.api', function (api) {}])

This syntax should be optional and defined per dependency:

// Source
angular.module('foo').service(function (foo /*ng-from ns*/, bar, qux /*ng-from my*/) {})

// Translates to
angular.module('foo').service(['ns.foo', 'bar', 'my.qux', function (foo, bar, qux) {}])
Read more comments on GitHub >

github_iconTop Results From Across the Web

527 – Defining a Nested Namespace Using Dot Notation
If you are defining a type that exists in a nested namespace, there are two ways to define the namespace. You can nest...
Read more >
C++ COM Interop: Using C# namespace with dot notation in c++
using namespace A::B::C;. and I get error C2653: A is not a class or namespace. The unmanaged project is referencing the managed project...
Read more >
Practice: Exploring Objects Using JavaScript: Dot notation
You accessed the object's properties and methods using dot notation. The object name (person) acts as the namespace – it must be entered...
Read more >
JavaScript Dot Notation, Namespace or Object System?
am writing a JavaScript lib. My question is, to have method chaining or not. This post is sort of a log of my...
Read more >
namespaces API - Read the Docs
Look up item via dot-notation. Parameters: name (str) – Key. Returns: Associated value. Usage::.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found