Skip to content

Instantly share code, notes, and snippets.

@khoand0000
Last active December 14, 2015 10:55
Show Gist options
  • Save khoand0000/13e75d8e904c54c08561 to your computer and use it in GitHub Desktop.
Save khoand0000/13e75d8e904c54c08561 to your computer and use it in GitHub Desktop.
Different between <a> and <button> button, ng-click & ui-sref
  • Same: use class="button"
  • Always try to using ui-sref first, just using ng-click if need to do something (not moving state) or change states dynamic (ui-sref doesn't support it)
  • Different:
<a> <button>
change state/url use ui-sref="" (no need create more functions, short code if just change state/url and not more complex code) or ng-click="changeUrl()" (use same <button>) only way using ng-click="changeUrl()" with $scope.changeUrl = function() { $state.go('tab.posts', {postId: postId});}
use ng-click no effect having effect. side effect: submit form automatically
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment