Skip to content

Instantly share code, notes, and snippets.

@s4553711
Created December 16, 2014 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s4553711/2f0a9032abe59a4da7c2 to your computer and use it in GitHub Desktop.
Save s4553711/2f0a9032abe59a4da7c2 to your computer and use it in GitHub Desktop.
Call angular js from legacy code
// Source: http://stackoverflow.com/questions/10490570/call-angular-js-from-legacy-code
var scope = angular.element($('#todoList')[0]).scope()
// The original behavior of click will add up a variable with 1 and show it on the view, but it fact it doesn't update the veiw until
// user click the UI to trigger this function
scope.clikc();
// If I do it in this way, the result will the same with my expect
scope.$apply(function() {
scope.click();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment