Javascript <;要求>;在Aurelia中使用enhance调用的globalResource组件中

Javascript <;要求>;在Aurelia中使用enhance调用的globalResource组件中,javascript,aurelia,Javascript,Aurelia,所以,我正在尝试在Angular 1 web应用程序中设置Aurelia,以便慢慢升级。我需要这样做,因为应用程序太大,不可能同时迁移所有内容 因此,在我的Aurelia文件夹中,我创建了一个包含两个组件的组件文件夹(Aurelia component.js和Other component.js及其视图Aurelia component.html和Other component.html),我不会放置javascript,因为它们只是两个具有一个属性的类,两者的html是相同的,唯一需要更改的是

所以,我正在尝试在Angular 1 web应用程序中设置Aurelia,以便慢慢升级。我需要这样做,因为应用程序太大,不可能同时迁移所有内容

因此,在我的Aurelia文件夹中,我创建了一个包含两个组件的组件文件夹(
Aurelia component.js
Other component.js
及其视图
Aurelia component.html
Other component.html
),我不会放置javascript,因为它们只是两个具有一个属性的类,两者的html是相同的,唯一需要更改的是文本属性值,以便我可以区分它们:

<template>
    <div>${text}</div>
</template>
如你所见,这将Aurelia放在窗口对象中,因此我可以从Angular应用程序访问它,稍后我将对此进行改进。 在我的angular应用程序中,我有以下指令:

'use strict';

function AureliaContainer() {
    function Link($scope, element, attrs) {
        window.aurelia.enhance(element[0]);
    }
    //
    return {
        restrict: 'A',
        link: Link
    };
}

module.exports = AureliaContainer;
我在我的应用程序根目录中使用以下设置:

app.directive('aureliaContainer', require('./directives/aurelia.container'));
从我的角度来看,这些div和我的指令调用了Aurelia的
enhance
函数:

<div aurelia-container>
    <aurelia-component></aurelia-component>
</div>
<div aurelia-container>
    <another-component></another-component>
</div>
然后,从
aurelia component.html
中,我使用以下命令调用它:

<template>
    <require from="./test-component"></require>
    <div>${text}</div>
    <test-component></test-component>
</template>
我真的不明白为什么会发生这个错误,我应该能够从另一个自定义元素中加载自定义元素,不是吗?或者当您使用
增强
时是否有限制

我还尝试在两个div中使用
setRoot
,但没有成功,只加载了其中一个

也许有更好的方法? 同样,我不能一次迁移整个应用程序,这是不可行的


提前感谢您的帮助。

首先,我对Aurelia的渐进增强一无所知。并且不能评论其是否适合您的场景

但我想知道您是否遗漏了一些Au依赖项(比如绑定或模板?)


这也许可以解释为什么当您希望它呈现模板时它会失败?

我会尝试这样做,但有趣的是,当我删除
时,没有加载的部分会再次开始加载。
<template>
    <h1>Header</h1>
</template>
<template>
    <require from="./test-component"></require>
    <div>${text}</div>
    <test-component></test-component>
</template>
Uncaught (in promise) TypeError: Cannot read property 'behaviorInstructions' of undefined
aurelia.use
    .defaultBindingLanguage()
    .defaultResources()
    .developmentLogging()
    .globalResources('resources/my-component');