角"未知提供商QUOT;经过微小误差咕噜在约曼的应用程序构建 [英] Angular "Unknown Provider" error after minification with Grunt Build in Yeoman app

查看:135
本文介绍了角"未知提供商QUOT;经过微小误差咕噜在约曼的应用程序构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在与咕噜构建在文书上士问题产生的角应用程序,使用咖啡,身材苗条,所有的库达最新的。 (这个应用程序只是生成了前几天与最新生成)。

I'm having problems with grunt build on a Yeoman generated Angular app, using Coffee and Slim, with all libraries up-to-date. (The app was just generated a few days ago with the most recent generator.)

咕噜构建咕噜服务器在最初工作的罚款。但经过使用咕噜服务器发展的几天,我发现咕噜构建已停止工作完全。

grunt build and grunt server both worked fine initially. But after a few days of development using grunt server, I discovered that grunt build had stopped working entirely.

有,我固定了几个不同的问题。最大的一个是,我不得不放弃修身完全是为了我的索引文件,并直接使用HTML,因为咕噜构建被莫名其妙地删除索引文件的80%,当它发布到 / DIST

There were a few different problems that I fixed. The biggest one was that I had to abandon Slim entirely for my index file and use straight HTML, since grunt build was inexplicably removing 80% of the index file when it published to /dist.

不幸的是,我得到了几乎一切解决后,我开始在我的角度指令之一收到此错误:

Unfortunately, after I got almost everything resolved, I started getting this error in one of my Angular directives:

未捕获的错误:未知提供商:aProvider< - 一个

这个问题似乎是在丑化。我认为它可能是报道了同样的问题<一href=\"http://stackoverflow.com/questions/20098680/angular-grunt-build-from-yeoman-breaks-my-app\">here,但我没有绝对的把握。我尝试了一些了一些解决方案,但只有为我工作的事情是手动生成从我的CoffeeScript干净的js文件,将文件复制到 / DIST ,和然后写入路径到 DIST / index.html的

The problem seems to be in uglify. I think it could possibly be the same problem reported here, but I'm not absolutely sure. I tried a number a number of solutions, but the only thing that has worked for me was to manually generate clean js files from my coffeescript, copy the files into /dist, and then write the paths into dist/index.html.

显然,这不是最佳的。我敢肯定有一个更合适的方法(可能完全在构建过程中去除微小,因为其他用户在上面的链接那样)做的咕噜,但我是新来的它,还没有想出如何要做到这一点。无论哪种方式,这将是一个解决办法。

Obviously that's not optimal. I'm sure there's a neater way to do it in Grunt (probably by removing minification entirely from the build process, as that other user did in the link above), but I'm new to it and haven't yet figured out how to do that. Either way, it would be a workaround.

我Gruntfile是pretty基本的:我只加了咕噜连接代理,咕噜-的contrib - 萨斯和咕噜纤薄到默认的文件。其实,我想在一个干净的,新生成的Gruntfile带给但它并没有建立任何好转。

My Gruntfile is pretty basic: I've only added grunt-connect-proxy, grunt-contrib-sass, and grunt-slim to the default file. In fact, I tried to bring in a clean, newly-generated Gruntfile but it didn't build any better.

这是失败的指令如下。该错误实际上是在控制器的一线大作吧, $ scope.showInput = FALSE 。什么是令人沮丧的是,一切都在咕噜服务器的伟大工程。我虽然建立的那一刻,它分崩离析完全。

The directive that's failing is below. The error actually comes up right in the first line of the controller, $scope.showInput = false. What's frustrating is that everything works great in grunt server. The moment I build though, it falls apart entirely.

myModule.directive "editable", ->

  controller = ($scope) ->
    $scope.showInput = false

    $scope.saveContent = -> 
      $scope.toggleContent()
      $scope.save()

  linker = (scope, element, attrs) ->    
    scope.toggleContent = -> 
      scope.showInput = not scope.showInput
      setTimeout((-> element.find('input').focus()), 100)

  return DDO = 
    restrict: 'E'
    controller: controller
    link: linker
    templateUrl: "template/editable.html"
    scope:
      editableType: "@"
      text: "="
      placeholder: "@"
      save: "&"

(模板是不是真的很重要,它只是有一个 NG-开关的切换使用 $ scope.showInput

如果任何人有任何建议,我倒是AP preciate它。

If anybody has any suggestions, I'd appreciate it.

推荐答案

这听起来像角对的依赖注入参数的名称依赖的共同问题。确保当您传递的依赖,你有依赖性的名称作为字符串,以便将角知道什么注入后缩小(因为字符串值不会在缩小过程中改变)。

It sounds like the common issue of Angular's reliance on the name of arguments for dependency injection. Make sure when you pass dependencies that you include the dependency names as strings so that Angular will know what to inject after minification (since string values won't be changed in the minification process).

myApp.controller('myCtrl', ['$scope', '$http', function($scope, $http) {

}])

从角文档: 上微小的注

From Angular docs: A Note on minification

这篇关于角&QUOT;未知提供商QUOT;经过微小误差咕噜在约曼的应用程序构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆