未知提供者:tProvider <- t
Unknown provider: tProvider <- t
我只在缩小代码(生产)时遇到此错误。
当我在 formly 中添加 'controller' 函数时创建了错误..
请查看我的代码,也许你会看到一些错误..
任何提示都会有用 ;)
依赖项:
"angular-formly": "~7.1.2",
"angular-formly-templates-bootstrap": "~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}"
@
)
你需要显式注入 $rootScope:
而不是($rootScope) -> {code...}
使用
['$rootScope', ($rootScope) -> {code...}]
否则,变量名称隐含了“$rootScope”依赖项。由于 $rootScope 在缩小过程中变成 $t angular 意味着你想注入不存在的 '$t'。
google ng-annotate 自动 'explicifies' 你的注射。
编辑:我不熟悉 coffeescript,所以请多多包涵 :)
我只在缩小代码(生产)时遇到此错误。 当我在 formly 中添加 'controller' 函数时创建了错误.. 请查看我的代码,也许你会看到一些错误.. 任何提示都会有用 ;)
依赖项: "angular-formly": "~7.1.2", "angular-formly-templates-bootstrap": "~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}"
@
)
你需要显式注入 $rootScope:
而不是($rootScope) -> {code...}
使用
['$rootScope', ($rootScope) -> {code...}]
否则,变量名称隐含了“$rootScope”依赖项。由于 $rootScope 在缩小过程中变成 $t angular 意味着你想注入不存在的 '$t'。
google ng-annotate 自动 'explicifies' 你的注射。
编辑:我不熟悉 coffeescript,所以请多多包涵 :)