Javascript 丑角

Javascript 丑角,javascript,angularjs,Javascript,Angularjs,我有一个正在演示的应用程序,想演示依赖注入是如何工作的。我有以下代码: wpApp.controller('ListCtrl', ['$scope', 'Posts', 'Pages', function($scope, Posts, Pages) { console.log('ListCtrl'); $scope.page_title = 'Post Listing'; Posts.query(function(res){ $scope.posts = res; })

我有一个正在演示的应用程序,想演示依赖注入是如何工作的。我有以下代码:

wpApp.controller('ListCtrl', ['$scope', 'Posts', 'Pages', function($scope, Posts, Pages) {
  console.log('ListCtrl');
  $scope.page_title = 'Post Listing';
  Posts.query(function(res){
    $scope.posts = res;
  })
  Pages.query(function(resp) {
    $scope.pages = resp;
  })
}])
但当我在代码上运行uglify时,我得到以下结果:

wpApp.controller("ListCtrl",["$scope","Posts","Pages",function(t,o,s){console.log("ListCtrl"),t.page_title="Post Listing",o.query(function(o){t.posts=o}),s.query(function(o){t.pages=o})}]);
然后应用程序就坏了。有没有什么地方我错过了


编辑-问题已解决。脚本中还有另一个依赖项注入,它丢失了,导致了所有的事情都变得疯狂。

尝试一下,因为你的丑陋省略了

wpApp.controller("ListCtrl",["$scope","Posts","Pages",function(t,o,s){console.log("ListCtrl");t.page_title="Post Listing";o.query(function(o){t.posts=o});s.query(function(o){t.pages=o})}]);

在绑定和缩小角度代码之前,将
ng annotate
gulp
grunt
一起作为构建过程的一部分使用
ng annotate
除了我的
tagsAny错误之外,页面上没有显示任何内容。在浏览器控制台中,我的意思是控制台中没有显示任何内容。请注意,Firefox没有显示任何内容,Chrome有一个错误。。。“angular.min.js?ver=1.5.5:40未捕获错误:[$injector:modulerr]”