小编epb*_*epb的帖子

Angular 1.5组件依赖注入

我一直在尝试component在项目中使用新的Angular 1.5 语法,但我无法弄清楚如何将依赖项注入组件定义.

这是我尝试将现有指令重构为组件:

angular
    .module('app.myModule')
    .component('row', {
      bindings: {
        details: '@',
        zip: '@'
      },
      controller: 'RowController',
      templateUrl: basePath + 'modules/row.html' // basePath needs to be injected
    })
Run Code Online (Sandbox Code Playgroud)

由于各种原因,我们将常量basePath作为templateUrl的一部分注入到我们的所有指令中.

如何在组件上执行此操作,因为组件定义不是函数?

angularjs angularjs-components

13
推荐指数
1
解决办法
3067
查看次数

标签 统计

angularjs ×1

angularjs-components ×1