문제

I have a problem with the external function OnLoginFail when invoking the function showFormAndHideMessage from it. I try using

 angular.element($("login")).scope().showFormAndHideMessage().$digest(); 

but it doesn't not work. I understand that scope() should give me access to controller in directive.

Login.js

  lobby.directive( 'login', function() {
    return {
    restrict: 'E',
    replace: false,
    templateUrl: 'lobby/login/login.html',
    scope: {},

         ....

    function OnLoginFail( error ) {
       alert( error.Message );
       angular.element($("login")).scope().showFormAndHideMessage().$digest();  

   }
도움이 되었습니까?

해결책

Scope only gives you direct access to parent scope if you aren't creating an isolate scope in your directive. You are isolating your scope in your directive with the following line:

scope: {}

EDIT

Per JPRO's comment, to fix this just delete that line in your directive's configuration.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top