2015-11-09 42 views
1

我只在缩小代码(生产)上出现此错误。 “角formly”:)未知提供者:tProvider < - t

相关性;当我里面添加formly .. “控制器”功能,请看我的代码,也许你会看到一些bug .. 任何提示,将是有益的 错误创建“〜7.1.2”, “角formly模板的自举”: “〜6.1.0”,

我的控制器代码:

.controller('NSearchBoxOnResultsController', ($rootScope) -> 
    @formFields = 
     [ 
     type: 'form_with_own_classes' 
     key: 'q' 
     defaultValue: @resultAsValue 
     templateOptions: 
      type: 'string' 
      label: '' 
      placeholder: I18n.t('homepage.placeholder') 
      wrapper_class: 'row input--primary modal__center-items search search_query' 
      input_container_class: 'col-xs-12' 
      onKeypress: ($viewValue, $modelValue, scope, event) => 
      if event?.which == 13 
       @submit() 
     controller: ($scope, $rootScope) => 
      @scope = $scope 
      @rootScope = $rootScope 
      @rootScope.$on('$locationChangeSuccess', (newValue, oldValue) => 
      if @scope.options?.formControl 
       @hash = window.location.hash.split('/') 
       @queryFromHash = @hash.slice(2, @hash.length).join('/') 
       @resultAsValue = decodeURIComponent(@queryFromHash) 
       @scope.options.formControl.$setViewValue(@resultAsValue) 
       @scope.options.formControl.$rollbackViewValue() 
     ) 
     ] 

    @submit = => 
     window.location = "/search/#all/#{@search.q}" 

    @ 
) 

回答

3

你需要明确注资$ rootScope:

代替($rootScope) -> {code...}

使用

['$rootScope', ($rootScope) -> {code...}]

否则, '$ rootScope' 依赖关系是变量名暗示。由于在您的缩小过程中$ rootScope变为$ t,因此角度意味着要注入不存在的'$ t'。

谷歌ng-annotate自动“解释”你的注射。

编辑:我不熟悉的CoffeeScript,所以请多多包涵:)

+0

但是,当我不注入在主控制器$ rootScope formly也在努力 - 但同样的错误。我认为注入主控制器没有改变任何东西.. – Darex1991

+2

'控制器:['$ scope','$ rootScope',($ scope,$ rootScope)=> {}]'。你应该查找ng-annotate。它会为你处理所有这些。 – j2L4e

+0

tnx帮助;) – Darex1991

相关问题