问题标签 [aurelia]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
17149 浏览

aurelia - Aurelia repeat.for 项目的访问索引

我有一个简单的repeat.for:

目前我正在使用:${$parent.items.indexOf(item)}. 有没有一个简写,比如角度的 {{$index}} ?

0 投票
4 回答
14269 浏览

javascript - Aurelia 的物业变更订阅

我的视图模型上有一个属性,我想根据它的值来监听和触发事件,如下所示:

这是Aurelia的特色吗?如果是这样,我将如何设置这样的订阅?

0 投票
2 回答
1636 浏览

aurelia - One Time Binding for Interpolated Value in Aurelia

Is there a way to change the default one-way binding of an interpolated value (e.g. ${someValue}) in the view to one-time?

Something like the angularjs {{::someValue}}

0 投票
1 回答
2383 浏览

aurelia - 多个模型视图中的 Aurelia 路由器配置

是否可以从多个视图模型配置路由器?

像下面这样的东西?

在其他视图模型中更改路由器配置:

0 投票
1 回答
588 浏览

javascript - 绑定到 Aurelia 中的命名空间属性

当绑定到属性(单向)时,有几个选项可以绑定attr-name.bind="variable"(也尝试过单向和一次性)或使用插值attr-name="${variable}",但如果您尝试绑定到命名空间元素,例如 xlink :href 你目前得到:

未捕获的命名空间错误:无法在“元素”上执行“setAttributeNS”:“”是属性的无效命名空间。

对于在控制器 page.js 中有以下内容:

以及 page.html 中的以下内容:

正如我所说的,上面的任何一个绑定都抛出了给定的错误。

关于如何绑定到这个命名空间属性的任何想法?

检测 bootstrap handleApp 函数以打印完整的堆栈跟踪:

Error: Failed to execute 'setAttributeNS' on 'Element': '' is an invalid namespace for attributes. at Error (native) at OoPropertyObserver.setValue (http://localhost:9000/jspm_packages/github/aurelia/binding@0.3.3/system/property-observation.js:200:26) at InterpolationBinding.setValue (http://localhost:9000/jspm_packages/github/aurelia/templating-binding@0.8.4/system/binding-language.js:214:35) at InterpolationBinding.bind (http://localhost:9000/jspm_packages/github/aurelia/templating-binding@0.8.4/system/binding-language.js:202:22) at View.bind (http://localhost:9000/jspm_packages/github/aurelia/templating@0.8.9/system/view.js:65:29) at ViewFactory.create (http://localhost:9000/jspm_packages/github/aurelia/templating@0.8.9/system/view-factory.js:173:22) at BoundViewFactory.create (http://localhost:9000/jspm_packages/github/aurelia/templating@0.8.9/system/view-factory.js:128:39) at Repeat.processItems (http://localhost:9000/jspm_packages/github/aurelia/templating-resources@0.8.6/system/repeat.js:105:36) at Repeat.bind (http://localhost:9000/jspm_packages/github/aurelia/templating-resources@0.8.6/system/repeat.js:60:22) at BehaviorInstance.bind (http://localhost:9000/jspm_packages/github/aurelia/templating@0.8.9/system/behavior-instance.js:67:39)

此外,如果我破解属性观察代码以显式设置它工作的命名空间,但这确实很笨拙并且可能很快就会中断。

https://github.com/aurelia/binding/blob/master/src/property-observation.js#L153-L159改为:

0 投票
2 回答
224 浏览

aurelia - aurelia:在您的 VM 中自定义定义的 VM

嗨,我正在寻找一种方法来在我当前的 VM 中添加新的 VM 对象有人能帮我怎么做吗?

这个想法是这应该输出

我到目前为止的代码

也试过

他们都给出了“我的名字”,没有变量名。所以我想它没有约束力

0 投票
1 回答
7144 浏览

routing - Aurelia:子路由器路由显示在“主”导航栏和 app.html 中的子视图中元素?

我们想要一个侧边栏菜单和一个“主要”区域。根据您的导航方式,侧边栏的菜单项将发生变化,并且新视图将加载到“主”区域中。

我创建了一个带有<router-view>元素的 app.html 和一个可以显示主路由器导航的 nav-bar.html。假设我最初将“管理”和“报告”作为路由(因此也是菜单项)。当用户单击“管理”时,我希望更新菜单以显示子路由(例如“用户”和“设置”)并在 app.html 中显示管理员视图模型<router-view>

最初我试图创建一个子路由器,但后来我必须<router-view>在 admin.html 中有一个新的内部(没有这个页面甚至不会加载)。相反,我希望 admin.html 视图显示在<router-view>app.html 中,并让子路由替换导航栏菜单中的“主”路由。

在 app.js 我有以下路由器配置:

在 users.js 中,我有以下代码:

最初,菜单应该是:
- 管理
- 报告

并且“welcome.html”应该是中的视图<router-view>(默认路由是“欢迎”)。

当用户单击(导航到)“管理”时,菜单应刷新为:
- 用户 - 设置

<router-view>.

但是,为了让它完全正常工作,我需要<router-view>在“users.html”中有一个进一步的内容,这并不是我真正想要的(我希望将视图加载到 app.html 中<router-view>)。

有没有办法在 Aurelia 中实现这一目标?我什至尝试将父路由器注入 Admin 构造函数(使用Parent.of(router)绑定),然后router.addRoute(). 路线被添加,但菜单没有更新(即使它是数据绑定的)。

0 投票
2 回答
2932 浏览

durandal - 如何在不使用 Gulp 手表的情况下为 Aurelia.io 应用程序提供服务

您如何运行 Aurelia 应用程序而不运行gulp watch而只是去localhost:9000. 理想情况下,我只想运行我的 nodejs 服务器,并且无需运行单独的任务(gulp 任务)即可正常运行。

我想构建 Aurelia 并以与 Durandal 相同的方式开始使用它。

0 投票
1 回答
975 浏览

javascript - Aurelia 中带有 3rd 方库的依赖注入 (di) 范例

我正在尝试使用 React 创建 Aurelia 自定义元素,通过在Aurelia Q & A上遵循此示例并发生以下异常:

我做错了什么?这是我的测试代码:

测试.html

我的元素.html

我的元素.js

0 投票
1 回答
1224 浏览

javascript - 使用 EventAggregator 更新 Aurelia 中的列表

我正在使用 app-contacts 演示来学习 Aurelia,是的,我知道,正如@Eisenberg 所提到的那样,它是不完整的,但是当我保存联系人或创建新联系人时,我想使用 EventAggregator 来通知 app.js。到目前为止,一切正常。我能够在 app.js 中接收联系人对象,但现在我想更新联系人列表,但它不起作用,当我保存联系人并更新 app.js 中的联系人列表时,它会被删除。

在 app.js 中添加的代码和 subscribe 方法在构造函数中被调用。

没有对 app.html 进行任何更改

如何更新列表?

更新 这对我有用,但不确定什么是正确的方法