angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

Can you expose more private global helper functions?

Open sym3tri opened this issue 13 years ago • 6 comments

I noticed a ton of useful functions defined here: https://github.com/angular/angular.js/blob/master/src/Angular.js

which are not exposed in the public api here: https://github.com/angular/angular.js/blob/master/src/AngularPublic.js#L26-L54

Many of these functions are extremely useful and I would like to use them in my app. It feels silly to have to rewrite them in my code just b/c I can't access them via the angular api.

Specifically I'm interested in parseKeyValue(), but many others seem useful too.

Any chance these could be exposed?

sym3tri avatar Oct 21 '13 20:10 sym3tri

directiveNormalize() would be handy, IMO

caitp avatar Oct 21 '13 22:10 caitp

+1

sathify avatar Oct 21 '13 23:10 sathify

+1, the only problem I see is with the docs: we'll have the global APIs section in the api reference get filled with them. A way to toggle their visibility would be nice.

rodyhaddad avatar Oct 22 '13 04:10 rodyhaddad

We should review this and see specifically what could be useful to export. I don't think blanket exporting all the internal functions is a good idea.

As far as parseKeyValue goes - yes, I think it's a good idea. (I might even try to rename it to parseQueryString). I'm more concerned about directiveNormalize. Frankly, I don't see a use case for it outside the Angular compiler. If you need to normalize directive names outside of Angular, you're probably not using Angular as effectively as you could be.

If you want to expose something, you should send a PR that does it along with an explanation of why you need it and docs. You should just expose one thing at a time. I don't think it's likely that a PR exposing a bunch of private APIs at once will get merged.

ksheedlo avatar Oct 22 '13 20:10 ksheedlo

@ksheedlo: the reason for it is for the same sorts of things its used for within angular, such as defining directives which perform the same 'class' of behaviour, but in sort of different cases and with different names. This can be pretty valuable in a lot of cases, and can help shrink code considerably. It can also help with getting normalized attribute names, which could potentially be helpful for some use cases. Of course it's a one-liner anyways, so easy to implement outside of angular, but just the same.

That said, life goes on without it, but in some cases it could help make code much tinier (and somewhat more robust)

caitp avatar Oct 22 '13 20:10 caitp

I think it makes sense to open issues on a per-case basis.

Adding public APIs also means that we're implicitly promising to never change them. This has bitten us in the past (with angular.copy, for instance). Some of these private helpers have implementations specific to Angular internals anyway.

btford avatar Jan 10 '14 01:01 btford