AngularJS

$scopeをng-controllerの外から参照する

メモ。AngularJSの$scopeをng-controllerの外から参照する方法。 angular.elementを使ってDOMをラップしたオブジェクトを取得し、scopeメソッドを呼ぶ。 AngularJS: API: angular.element 試したのはAngularJS 1.2.27。 test.html <html> <body> <button type="button" onclick="test()">test</button> <div ng-app="myApp"> </div></body></html>