Yeoman角度生成器:开发服务器工作,但在构建之后抛出一个infi-digest错误

时间:2014-10-01 23:11:42

标签: angularjs gruntjs yeoman yeoman-generator-angular

导致问题的代码:

angular.module('myApp')
  .controller('metaCtrl', function ($scope) {
        $scope.$watch(function (){ return $(document).height() }, function(val){
            $scope.config = {minHeight: val}
        });
  });

不知怎的,config.minHeight的值会在每次调用$ watcher函数时引发。

已经花了4个小时试图调试它。

非常感谢任何帮助。

grunt开发服务器与dist文件夹服务有什么不同?

1 个答案:

答案 0 :(得分:1)

我认为你需要为依赖注入提供字符串文字。这是因为在缩小时,您的变量名称将被细分,您的$scope将会消失。它适用于开发服务器,因为在开发服务器JS文件没有缩小。但在分销方面,他们是。

angular.module('myApp')
//inject your $scope using inline annotation so that it doesn't break upon minification.
 .controller('metaCtrl', ['$scope', function ($scope) {
    $scope.$watch(function (){ return $(document).height() }, function(val){
        $scope.config = {minHeight: val}
    });
}]);