我正试图通过指令显示模型框,我不知道我哪里出错但我的指令根本没有被篡改。任何人都可以建议帮助。谢谢。
<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
};
});
}());
我正试图通过指令显示模型框,我不知道我哪里出错但我的指令根本没有被篡改。任何人都可以建议帮助。谢谢。
答案 0 :(得分:0)
此字符串:
'add-genaral.form.client'
单词&#39; general&#39;中有错误,您使用此字符串从网址获取模板
/modules/institutions/client/views/add-genaral.form.client.html
你确定它是正确的吗?