0
沒有顯示我有角以下代碼塊:AngularJS時間和日期在生產
app.controller('timeCtrl', ['$scope', function ($scope) {
$scope.date = ' EEE, d LLLL yyyy';
$scope.time = ' h:mm:ss a'
}]);
app.directive("myCurrentTime", function(dateFilter){
return function(scope, element, attrs){
var format;
scope.$watch(attrs.myCurrentTime, function(value) {
format = value;
updateTime();
});
function updateTime(){
var dt = dateFilter(new Date(), format);
element.text(dt);
}
function updateLater() {
setTimeout(function() {
updateTime(); // update DOM
updateLater(); // schedule another update
}, 1000);
}
updateLater();
}
});
當我運行我在我的本地開發環境的應用程序,時間和日期顯示就好了。但是當我部署到生產環境時,時間和日期不會顯示,並且出現「錯誤:[$ injector:unpr]」日誌。
任何想法都讚賞!
你可以發佈JSFiddle嗎?沒有HTML,Angular總是很難調試,特別是在處理指令時。錯誤也導致我相信這可能是指令使用的問題。 – joh04667
https://jsfiddle.net/Lf8bd86a/ –
在將產品部署到生產環境之前,您是否正在使用可生成腳本縮小版本的產品? – Antipod