BrumIT - like Reddit, but for Birmingham

OK, so this isn’t actually a real thing, but rather the result of a tutorial on using Angular and Firebase to build a real time Reddit clone:

There is absolutely no deviation from the tutorial here (apart from a couple of minor fixes to bugs in the source), and is somewhat feature poor, but the basics are here and they work. If you wanted to submit some of your own links (you’ll need to register first) feel free, but I doubt anything will happen with them.

For any that are interested, here is my source code.

EDIT: and now it’s not working :frowning:.

The error I’m getting (which you can see at the above URL in the console) is Error: [$injector:unpr] Unknown provider: aProvider <- a, which I think has something to do with the minification, but I don’t know. Anyone got any ideas?

EDIT 2: I’ve literally changed nothing, built it another time and deployed it, and now it’s working again. :confounded:

Doesn’t seem to work for me, on Ubuntu/Firefox:

Error: [$injector:unpr] Unknown provider: aProvider <- a$injector/unpr?p0=aProvider%20%3C-%20a

I really do need to learn a frontend JS framework. Unfortunately it has to get in the queue after Laravel, Node, Docker, Ansible and PHP generators (and probably a bunch of things I can’t remember). Bah!

The error’s because you minified your code.

In your source code, you probably had this:

function something(someDependency) {}

but minified, that’s

function something(a) {}

and angular doesn’t know what a is.

Instead, use the minification-friendly notation and wrap that function in an array like so:

['someDependency', function (someDependency) {}]

This way when it’s compiled, the param name will still be a but angular will know what the dependency is from the string.

You can pass that array anywhere angular expects a function with Dependency Injection.


Was about to say: minifying angular code breaks dependency injection, but Jack has explained it excellently. Use the minifying-friendly declarations. Also, don’t minify unless you actually need to, and if you need to, provide source maps. :slight_smile:


I’m so very new at this JavaScript framework gig that I’m pretty reliant upon whatever various tutorials tell me, and this one just doesn’t cover things like source maps and the like. I suppose this is my opportunity to go off and learn about them myself.

What I’d be really interested in are some tutorials which cover TDD in JavaScript.

I advise not minifying, unless real world usage shows that you’ll get a large benefit from doing so which outweighs the harm you do to the commons. Which isn’t the case for a tutorial :slight_smile: looks to summarise mocha (which is what I use) quite well.

1 Like

I’ve returned to this because I want to make some improvements and try to use it as a launchpad to teach myself some of the more advanced features of Angular by seeing if I’m able to complete the optional tasks in the tutorial.

So the first thing I did was try fixing the dependency injection minification thing described by @jackweirdy - which you can see here - only I thinking I did something wrong as I’ve still got the same error as before.

Taking a deeper look, the homepage seems to work fine, but as soon as you enter either the Login or Register pages, it falls over, so whatever the problem is, it’s related to this in some way, but I can’t figure out what.

Can anyone take a look and help me out please? Thanks.

PS, again, this works fine unminimised. I know I could probably keep it unminimised, as has been suggested, but minification seems to be something which a lot of people do, so it’s worth arming myself against problems like this in the future by learning how to solve these problems now.

UPDATE: I’ve fixed it thanks to this little hack. I’ve also made this change, which didn’t break it, but I’m not sure if it’s required or not.

Proudly sponsored by Bytemark