我想知道,爲什麼通過一個簡單的變量作爲參數傳遞給過濾器不工作:傳遞一個變量角度濾波
的Javascript:
var Test = Test || {};
Test.Constants = {};
Test.Constants.DateFormat = 'dd/MM/yyyy hh:mm';
function Main($scope){
$scope.date = new Date();
$scope.format = 'dd/MM/yyyy hh:mm';
$scope.format2 = Test.Constants.DateFormat;
}
HTML:
<div>
{{date}}<br> // "2016-06-13T10:29:49.935Z"
{{date | date: 'dd/MM/yyyy hh:mm'}}<br> // 13/06/2016 02:29
{{date | date: format}}<br> // 13/06/2016 02:29
{{date | date: format2}}<br> // 13/06/2016 02:29
{{date | date: Test.Constants.DateFormat}} // Jun 13, 2016
</div>
爲什麼最後一個沒有格式化?
由於
你試過路過'$ scope.format2'呢? – AranS