$scope.dates = new Date();
var ed = new Date($filter('date')($scope.dates,'hh:mm:ss'));
在第二行我想获得时间,但我得到引用错误。
我有什么问题?
(function(){
var app = angular.module('notesApp',['angular-markdown-editable']);
app.controller('notesController', function($scope, $interval){
function updateTime() {
$scope.dates = new Date();
var ed = new Date($filter('date')($scope.dates,'hh:mm:ss'));
alert(ed);
}
...
您需要在控制器声明中注入$filter
,如:
app.controller('notesController', function($scope, $interval, $filter){ // <-- filter was added at the end
我知道这个问题是关于angular的,但我建议你考虑使用javascript日期函数,如:
var date = new Date();
var seconds = date.getSeconds();
var minutes = date.getMinutes();
var hour = date.getHours();