Вопрос

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