我正在使用 Angular Material 的 md-dialog 功能,但在使日期过滤器正常工作时遇到了一些问题。也许有人可以发现它并让我知道他们是否对如何进行这项工作有任何想法。我可以看到 {{item.presentation.end_time}} 和 {{confSessionObj.session_nr}} 正在工作,但是当我放置角度日期过滤器时,它无法识别它。
这是我的代码。
JS
$scope.showAdvanced = function(ev, confSession) {
var sessionID = confSession.id;
$.ajax({
type: "GET",
url: "/session-detail.php",
data: {id: sessionID},
success: function(data, response){
data = data.replace(/\\n/g, "\\n")
.replace(/\\'/g, "\\'")
.replace(/\\"/g, '\\"')
.replace(/\\&/g, "\\&")
.replace(/\\r/g, "\\r")
.replace(/\\t/g, "\\t")
.replace(/\\b/g, "\\b")
.replace(/\\f/g, "\\f");
$scope.returnedObj = JSON.parse(data);
$mdDialog.show({
locals: { confSessionObj: confSession, returnedObj: $scope.returnedObj },
controller: DialogController,
targetEvent: ev,
template:
'<div class="md-dialog-container">' +
'<md-dialog aria-label="Session Detail">' +
'<form ng-cloak>' +
'<md-toolbar md-scroll-shrink>'+
'<div class="md-toolbar-tools">'+
'<h4 style="color: #fff;">Session Details</h4>'+
'</div>'+
'</md-toolbar>'+
'<md-dialog-content>'+
'<md-list-item>'+
'<div class="md-dialog-content" id="dialog">'+
'<p class="md-body-2"><span class="md-custom-title">Session Title:</span> {{confSessionObj.session_nr}} - {{confSessionObj.session_name}}</p>'+
'<table class="table table-bordered table-striped table-hover table-responsive" id="dialogtable">'+
'<tr id="theader">'+
'<thead>'+
'<th>Talk Title</th>'+
'<th>Start Time</th>'+
'<th>End Time</th>'+
'<th>Speaker Name</th>'+
'</thead>'+
'</tr>'+
'<tr ng-repeat="item in returnedObj">'+
'<td>{{item.presentation.title}}</td>'+
'<td>{{item.presentation.start_time | date: "MM/dd/yyyy h:mma"}}</td>'+
'<td>{{item.presentation.end_time | date: "MM/dd/yyyy h:mma"}}</td>'+
'<td>{{item.speakers.firstname}} {{item.speakers.lastname}}</td>'+
'</tr>'+
'</table>'+
'</div>'+
'</md-list-item>'+
'</md-dialog-content>'+
'<md-dialog-actions layout="row">'+
'<md-button class="md-raised" ng-click="cancel()">Close</md-button>' +
'</md-dialog-actions>'+
'</form>'+
'</md-dialog>'+
'</div>',
parent: angular.element(document.body),
preserveScope: true,
clickOutsideToClose:true,
fullscreen: $scope.customFullscreen
});
},
error: function(e){
console.log(e.message);
}
});
};
function DialogController($scope, $mdDialog, confSessionObj, returnedObj) {
$scope.confSessionObj = confSessionObj;
$scope.returnedObj = returnedObj;
$scope.cancel = function() {
$mdDialog.cancel();
};
}