2014-07-08 3 views
3

저는 drupal angularjs 모듈에서 작업 해 왔습니다. 부트 스트랩 UI를 설치했는데 제대로 작동합니다. 하지만 모달 상자를 사용하면 작동하지 않습니다. 컨트롤러 내부TypeError : i.match가 함수가 아닙니다.

코드 :

$scope.alertOnEventClick = function(event, allDay, jsEvent, view){ 
    $scope.alertMessage = (event.title + ' was clicked '); 
    console.log($modal); 

    var modalInstance = $modal.open({ 
     //templateUrl: Drupal.settings.angularjsApp.basePath + '/ng_node/calender/popup', 
     template: "<div class='modal-header'><h3 class='modal-title'>I'm a modal!</h3>" + 
      "</div><div class='modal-body'><ul><li>jfksdfhjksd</li><li>jfksdfhjksd</li><li>jfksdfhjksd</li></ul></div>"+ 
      "<div class='modal-footer'><button class='btn btn-primary'>OK</button>" + 
      "<button class='btn btn-warning'>Cancel</button></div>", 
     controller: ModalInstanceCtrl, 
     scope: $scope 
    }); 



    function ModalInstanceCtrl($scope, $modalInstance) { 
    console.log("controller class called") 
    }; 

는 여전히 부트 스트랩 UI를 팝업 모델과 문제에 직면하고있다.

답변

6

범위 : $ scope는 내게 적합하지 않습니다. 단지이에 지시 정의에 범위 할당을 변경하여

app.directive('contactAssociation', function() { 
    return { 
     templateUrl: 'contactAssociation.html', 
     restrict: 'E', 
     scope: { 
      contact:"=", 
      isSelected : false 
     }, 
     controller: contactAssociationController 
    }; 

을 수행하여 "a.match 기능없는 형식 오류는"내가 가진 곳 난 그냥 비슷한 정체 불명의 각도 문제를 통해 일

app.directive('contactAssociation', function() { 
    return { 
     templateUrl: 'contactAssociation.html', 
     restrict: 'E', 
     scope: { 
      contact:"=", 
     }, 
     controller: contactAssociationController 
    }; 

모든 것이 다시 시작되었습니다. 부적절한 범위 지정을 수행하여 각도가 이상한 오류를 던지거나 문제를 적절히 점검하지 않는 것 같습니다.

다음은 지시문 정의에 대한 유효한 범위 옵션입니다.

범위 : 사실 // 상속 부모 범위

범위 : 거짓 // 사용 부모 범위

범위 : {} //

+1

하지만 무슨 일이 "에 발생 고립 isSelected? " –

+2

@DaveKaye $ 범위에 추가하려면 컨트롤러 함수로 옮겨야했습니다. – dwbartz

+0

Ah gotcha. 나는 링크를 사용하여 비슷한 일을하려고합니다. –

11

I too faced this problem earlier. With further investigation I could understand that as per angular guidelines, the isolated scope can only have the attributes of the custom directives. It throws error if we try to create a new scope value which doesn't matches with any of the attribute.

myModule.directive('directiveName', function factory() { 
    return { 
    ... 
    scope: { 
     'attrName': '@', // OK 
     'attrName2': '=localName', // OK 
     'attrName3': '<?localName', // OK 
     'attrName4': ' = name', // OK 
     'attrName5': 'name', // ERROR: missing mode @&= 
     'attrName6': 'name=', // ERROR: must be prefixed with @&= 
     'attrName7': '=name?', // ERROR: ? must come directly after the mode 
    } 
    ... 
    } 
}); 
관련 문제