【发布时间】:2017-08-10 15:03:14
【问题描述】:
是否可以使用动态 templateUrl 创建 AngularJS 组件? 意味着我想将服务注入到为我提供模板基本路径的组件中:
即:templateUrl: configuration.baseScriptPath + '...html'
使用 Directive 是可能的,但是如何使用 Component 做到这一点?
angular.module('runtime')
.component('textInput', {
templateUrl: /*configuration.baseScriptPath + */'fd/components/text_input_instance.html',
controller: [
'$scope', '$element', 'focusInputGroup', 'configuration',
function ($scope, $element, focusInputGroup, configuration) {
【问题讨论】:
-
如果它在指令中工作,它也应该在组件中工作,因为'templateUrl'属性没有被修改..
-
我想注入配置,以便在 templateUrl 中可用。
-
你能分享你的组件代码吗?
-
刚刚添加。评论显示了我想要完成的事情,但是如何注入配置?
标签: javascript angularjs