AngularJS Module 외부에서 Controller 내 함수 호출하는 방법
jQuery 와 AngularJS 를 같이 사용하고 있다면 혹시나 필요할 때가 있을 수도 있습니다.
HTML 코드
1 2 3 4 5 | <div id= "Container" ng-app= "MainApp" ng-controller= "MainController" > <span> Module 외부에서 Controller 내 함수 호출하는 방법 </span> </div> |
JS 코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | angular.module( 'MainApp' , []) .controller( 'MainController' , function ($scope) { $scope.start = function () { alert( 'Scope Start Function' ); } }); function Scope() { var scope = angular.element(document.getElementById( "Container" )).scope(); return scope; } $( function () { Scope().$apply( function () { Scope().start(); }); }); |
광고
광고
'Javascript > AngularJS' 카테고리의 다른 글
[AngularJS] angular.equals 객체(Object) 또는 값이 같은지를 비교하는 함수 (0) | 2015.10.13 |
---|---|
[AngularJS] $http 를 이용해서 POST 방식으로 데이터 전송하는 방법 (Ajax 통신) (0) | 2015.09.17 |