Cake views are just presentation-flavored fragments that fit inside
an application’s layout. For most applications they’re HTML mixed
with PHP, but they may end up as XML, CSV, or even binary data.
Layouts are presentation code that is wrapped around a view, and
can be defined and switched between
if the HTTP method of the
request was POST, try to save the data using the Post model.
"the reason to use the bar is because you're switching content via JavaScript rather than loading a new page. This makes sense since the browser's own loading indicator may not get triggered. "
DI means that you can declare components very freely and then from any other component, just ask for an instance of it and it will be granted
do test-driven development iteratively in AngularJS!
only do DOM manipulation in a directive
with ngClass we can dynamically update the class;
ngBind allows two-way data binding;
ngShow and ngHide programmatically show or hide an element;
The less DOM manipulation, the easier directives are to test, the easier they are to style, the easier they are to change in the future, and the more re-usable and distributable they are.
still wrong.
Before doing DOM manipulation anywhere in your application, ask yourself if you really need to.
a few things wrong with this
jQuery was never necessary
use angular.element and our component will still work when dropped into a project that doesn't have jQuery.
just use angular.element
the element that is passed to the link function would already be a jQuery element!
directives aren't just collections of jQuery-like functions
Directives are actually extensions of HTML
If HTML doesn't do something you need it to do, you write a directive to do it for you, and then use it just as if it was part of HTML.
think how the team would accomplish it to fit right in with ngClick, ngClass, et al.
Don't even use jQuery. Don't even include it.
ry to think about how to do it within the confines the AngularJS.
In jQuery, selectors are used to find DOM elements and then bind/register event handlers to them.
Views are (declarative) HTML that contain AngularJS directives
Directives set up the event handlers behind the scenes for us and give us dynamic databinding.
Views are tied to models (via scopes). Views are a projection of the model
In AngularJS, think about models, rather than jQuery-selected DOM elements that hold your data.
AngularJS uses controllers and directives (each of which can have their own controller, and/or compile and linking functions) to remove behavior from the view/structure (HTML). Angular also has services and filters to help separate/organize your application.
Think about your models
Think about how you want to present your models -- your views.
using the necessary directives to get dynamic databinding.
Attach a controller to each view (using ng-view and routing, or ng-controller)
Make controllers as thin as possible.
You can do a lot with jQuery without knowing about how JavaScript prototypal inheritance works.