2016-11-22 7 views
0

私はモデルボックスをディレクティブで表示しようとしていますが、どこが間違っていたのか分かりませんが、私のディレクティブは全くcaled.Can誰もhelp.Thanksを提案してください。angularjsのディレクティブを呼び出す方法

<div class="modal fade" id="institutionModal" role="dialog"> 
    <div class="modal-dialog"> 
     <!-- Modal content--> 
     <div class="modal-content">  
      <common-directive-institution field="field" data="data" ng-if="showInstitutionModal"></common-directive-institution> 
     </div> 
    </div> 
</div> 
<button type="button" ng-click="editInstitutionModal('general')" class="btn btn-white">Edit</button> 

私のJS、

$scope.editInstitutionModal = function (type) { 
    $scope.field = {}; 
    $scope.showInstitutionModal = false; 
    if (type === 'basicedit') { 
     $scope.field.field_type = 'edit-institution.form.client'; 
     $scope.field.formName = 'Edit institution (' + vm.institutionObj.name + ')'; 
     $scope.field.saveText = 'Update'; 
    } 
    if(type === 'general'){ 
     $scope.field.field_type = 'add-genaral.form.client'; 
     $scope.field.formName = 'General Info'; 
     $scope.field.saveText = 'Save';   
    } 
    $timeout(function() { 
    $scope.showInstitutionModal = true; 
    $('#institutionModal').modal('show'); 
    $scope.$apply(); 
    }, 10); 
}; 

私のディレクティブ、

(function() { 
    'use strict'; 

    angular 
      .module('users') 
      .directive('commonDirectiveInstitution', function ($http, $compile) { 

      var getTemplateUrl = function (field) {   
       var type = field.field_type; 
       var templateUrl = '/modules/institutions/client/views/'; 
       templateUrl += type + '.html'; 
       return templateUrl; 
      }; 

      var linker = function (scope, element) { 
       var templateUrl = getTemplateUrl(scope.field); 
       $http.get(templateUrl).success(function (data) { 
       element.html(data); 
       element.removeAttr('style'); 
       $compile(element.contents())(scope.$parent); 
       }); 
      }; 

      return { 
       template: '<div style="display:none">{{field}}</div>', 
       restrict: 'E', 
       scope: { 
       field: '=' 
       }, 
       replace: true, 
       link: linker 
      }; 
      }); 
}()); 

私はディレクティブを通じてモデルボックスを表示しようとしていますし、私は私が間違っていた場所を確認していないが、私のディレクティブがあります誰も助けてください。ありがとうございます。

+1

テンプレート: '

{{field}}
' このテンプレートには何も表示されません。表示スタイルを変更します。 ああ、私の悪い、あなたがスタイルを削除参照してください。 –

+0

関連はありませんが、ここに入力ミスがあります:add-genaral.form.clientこれは何かを壊したかもしれません。 –

+0

ありがとうございました...私の間違いbcozは冗談を忘れる..........申し訳ありません – MMR

答えて

0

この文字列:

'add-genaral.form.client' 

あなたはURL

/modules/institutions/client/views/add-genaral.form.client.html 

からテンプレートを取得するには、この文字列を使用し、「一般」の単語でのミスを持っていますが、それは正しいですか?

+0

私はそれを変更しましたが使用しません – MMR

関連する問題