Created
December 16, 2014 02:31
-
-
Save s4553711/2f0a9032abe59a4da7c2 to your computer and use it in GitHub Desktop.
Call angular js from legacy code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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