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