Angular for Designers
A colleague asked me "Is it about graceful degradation?", and the answer is no it's not. It is about the ability of a designer or a UX specialist to lead the behavior as well as the aesthetics of a web-application, during development.
A minimal Angular app, with an overlay
Note too that all the content for this app is static HTML. Normally you'd use Angular to bind in data from JSON. The two "previous blogged about" articles do just that. For this blog entry, I'm only trying to sell the view-all-panels-together aspect of the proposition.
Commenting out the Angular import
This is the big benefit for me. Designers, or indeed newbies to a project, will load up an Angular page in a running app with Angular turned off. They will then be able to see all the panels/divs/overlays concurrently visible within the page, whether or not the application would function like that. All will be very-nearly styled appropriately, as CSS will still work as it would in the final app.
Here is the same one-page demo as before, with Angular 'turned off'. Note the 'kittens' button does not function.
Here is the source for it. I swear the only difference is the 'script' tag that would have dragged in Angular - I've commented it out.
Hacks I've had to do to make this work
'overlayClass' is one scoped variable that is only used once. It's definition:
$scope.overlayClass = "white_content";
The place where it is used is the overlay div itself:
<div ... ng-class="overlayClass">
This is a hack that is needed. Here is what happens without it. Note that the second div is not visible (the button is still non functioning)
Here is the source for it. The only difference versus the previous one is the ng-class usage has been swapped 'back' to a hardcoded class="white_content", as per ordinary HTML usage.
This kludge is needed to support the design-mode I'm advocating for. At least, unless the Angular team make class vs style co-existence a little smoother :)
Other 'new' tools a designer would use
Tin.cr - edit your CSS while playing with a functional AngularJs app, and save directly back to the file-system (before doing a commit).
Angular Batarang - fiddle or inspect your Angular model in your running Angular app. Here's that running:
A Github thought
Obviously I'm misusing Github here. I could have had three repos or three branches, and used Github's own diff mechanism to show that the differences I claim, are the only differences. But for a few stymying factors - 1) you can fork your own repo, and 2) you can only have one branch that publishes to github-pages. I hope that one of the things those guys do with their $100m is enhance the capabilities of Github-Pages :)
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)