啊。经过反复试验:
<dmodal visible="$root.showMiscModal">
</dmodal>
模板文件:
<style>
@media (min-width: 768px) {
.modal-dialog {
width: 800px !important;
margin: 30px auto;
}
}
<span>this is the Status Changes template test4</span>
<div><span style="float:left;width:150px">Name</span> <span style="float:left; width:150px">Date</span> <span style="float: left; width:50px">Old</span> <span style="float: left; width:50px">New</span> Note</div>
<div ng-repeat="s in statusChanges">
<span style="float:left;width:150px">{{s.Name}}</span> <span style="float:left; width:150px">{{s.ChangeDate|date:"MM/dd/yyyy HH:mm"}} </span> <span style="float: left; width:50px">{{s.OldStatus}}</span> <span style="float: left; width:50px">{{s.NewStatus}}</span> {{s.Note}}
</div>
指令:
angular.module("aps").directive("dmodal",
function($rootScope) {
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">×</button>' +
"</div>" +
'<div class="modal-body" ng-include="selectedTemplate"></div>' +
"</div>" +
"</div>" +
"</div>",
restrict: "E",
transclude: false,
replace: true,
scope: true,
link: function postLink(scope, element, attrs) {
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;
$rootScope.showMiscModal=false;
});
});
}
};
});
$scope.showInternalNotes = function() {
$rootScope.showMiscModal = true;
$scope.selectedTemplate = "/desktopmodules/mvc/TechSheetMaint/AngularTemplates/InternalNotes.html?"+Math.floor((Math.random() * 10000000) + 1);
$scope.getStatusChanges()
};
$scope.showCustomerContact = function() {
$rootScope.showMiscModal = true;
$scope.selectedTemplate= "/desktopmodules/mvc/TechSheetMaint/AngularTemplates/CustomerContact.html?"+Math.floor((Math.random() * 10000000) + 1);
$scope.getStatusChanges()
};
$scope.showStatusChanges = function() {
$rootScope.showMiscModal = true;
$scope.selectedTemplate = "/desktopmodules/mvc/TechSheetMaint/AngularTemplates/StatusChanges.html?"+Math.floor((Math.random() * 10000000) + 1);
$scope.getStatusChanges();
};
阿贾克斯:
$scope.getStatusChanges = function() {
const deferred = $q.defer();
const successFunction = function(response) {
if (!checkLogin(response, "getStatusChanges")) return;
$scope.statusChanges = response.data;
//alert(JSON.stringify(response.data));
deferred.resolve();
};
const failureFunction = function(data) {
console.log(`Error${angular.toJson(data)}`);
deferred.reject();
};
TechSheetFactory.getStatusChanges(successFunction, failureFunction,$scope.TechSheetInfo.WorkOrder.WorkOrderID);
return deferred.promise;
};