Skip to content

Instantly share code, notes, and snippets.

@krawaller
Last active January 27, 2016 08:03
Show Gist options
  • Save krawaller/8fe9c4d04c9c42be4896 to your computer and use it in GitHub Desktop.
Save krawaller/8fe9c4d04c9c42be4896 to your computer and use it in GitHub Desktop.
Grokking angular by claims
  • ng-submit * only makes sense on a <form> tag * is just an event handler much like ng-click
  • ng-options * only makes sense on a <select> tag * enables us to have objects as selected values instead of just strings * saves us from having to type out <options ng-repeat="..." ... /> * provides additional shortcut for <optgroup> through :groupBy
  • ng-click
  • should always be a method call, don't do assignments as that relies on brittle scoping and is hard to test
    
  • the above is less true if you aren't using scope but instead `ng-controller=SomeController as some` and can explicitly assign to a variable in that scope like `ng-click="some.aVariable = someValue"`.
    
  • inside an `ng-repeat` will commonly mean passing the `ng-repeat` variable to the callback
    
  • ng-class
  • is a shorthand to conditionally set css classes
    
  • looks like `ng-class="{classname: cond, classname: cond, ...}"`
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment