The Angular Menagerie is a little project I built in Angular. While I used a tutorial as a starting point, I’m not interested in simple paint by numbers programming, so I worked in a good deal of remixing. This approach leads to a level of “bonus education” and psychological torture that one just doesn’t get otherwise. One of the bonus lessons I got with this experiment involved <announcer voice>Primitives in the Chain of Prototypal Inheritance.</Announcer_voice> What is that, anthropology? No! Let the following tale of woe be a lesson to all those juniors who come after me.
The Angular app I built is a “store” that gets its inventory of product objects from JSON. I wanted to use a modal view to display the reviews they contained. So 2012, right? Remember, it’s about the pain of learning. Since I was already using Bootstrap for layout I first tried its built-in modal. After much pain I learned (see how that works) that there was a documented Bootstrap/Angular incompatibility, so I switched to an Angular-only modal based on Adam Albrecht’s walkthrough.
Depending on how you set up your directive, its scope can be parent scope, a new child scope, or an isolate scope. In Albrecht’s how-to, he’d set up an isolate scope, so I’d simply preceded from there. I probably should have just switched to scope: true, but learning. An isolate scope is basically just an isolated scope. Why not, then, CALL them “Isolated Scopes” or “Scopes of Isolation” or such? Scientifically speaking, the old “adjective+noun” approach used by grammarians and pedestrians just sounds too grammestrian. An isolate scope is a way of turning off prototypal inheritance so that re-used code doesn’t interfere with parent code it’s dropped into. It’s like a scope diaper. Thus, baby scopes (who adorably refer to themselves as isowate scopes) can do their business, and get passed around to parent scope or uncle scope without making a mess.