2016-05-22 7 views
0

AngularとjQueryを使用してmodalを作成しています。このディレクティブを使用していますのでangular+jQuery modalです。角型とjQueryのモーダル - 未定義は関数ではありません

$element is not defined.

$element.modal('show'); 

誤差の変化にそれを変更する場合

$(element).modal('show'); 

:について

undefined is not a function

そして、私はこのエラーを取得していますdirectiveため

私のコード:任意の助け

mymodal.directive('modal', function() { 
    return { 
     template: '<div class="modal fade">' + 
      '<div class="modal-dialog">' + 
      '<div class="modal-content">' + 
       '<div class="modal-header">' + 
       '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>' + 
       '<h4 class="modal-title">{{ title }}</h4>' + 
       '</div>' + 
       '<div class="modal-body" ng-transclude></div>' + 
      '</div>' + 
      '</div>' + 
     '</div>', 
     restrict: 'E', 
     transclude: true, 
     replace:true, 
     scope:true, 
     link: function postLink(scope, element, attrs) { 
     scope.title = attrs.title; 

     scope.$watch(attrs.visible, function(value){ 
      if(value == true) 
      $(element).modal('show'); 
      else 
      $(element).modal('hide'); 
     }); 

     $(element).on('shown.bs.modal', function(){ 
      scope.$apply(function(){ 
      scope.$parent[attrs.visible] = true; 
      }); 
     }); 

     $(element).on('hidden.bs.modal', function(){ 
      scope.$apply(function(){ 
      scope.$parent[attrs.visible] = false; 
      }); 
     }); 
     } 
    }; 
    }); 

ありがとう!もっとコードが必要な場合は、私はそれを掲示するでしょう。

答えて

1

Fixed Demoは、あなたのコードは完全に正確であると思います。

bootstrap.min.jsが読み込まれていないため、動作しないのはなぜですか。

bootstrap.min.jsにはhttpsを使用し、jQueryには2.0.0を使用するだけです。

関連する問題