我们正在考虑将 Aurelia 用于新应用。我来自 Angular 1 背景(接触过 Angular 2)。 Aurelia 看起来相当不错,我真的很喜欢他们如何承担起维护开发人员工作流程的责任。但是我有一些问题似乎无法找到答案:
1) 有两种一般方法(据我所知)可以在页面中包含 Web 组件。这些是 <compose>并编写自定义元素。我的问题是,Angular 非常强调作用域(即 DOM 中特定点的作用域)。我想知道“范围”中有什么(即可用于绑定(bind)表达式)与组合和自定义元素。我的意思是,子模板中是否有父 View 模型?如果是这样, subview 模型属性是否隐藏/隐藏父 View 模型属性?
2) 在 Angular 2 中,有关于如何将数据传入和传出组件的指南。我们不应该更改绑定(bind)到组件的非基元(因为这会强制 Angular 2 的更改检测始终进入该组件分支以检查所有属性)。
在 Aurelia 的组件中传入和传出数据是否有任何指南/信息?我的意思是,从我读过的内容来看,听起来我只会使用 value.bind绑定(bind)到所有 @bindable特性。那是对的吗?这些是默认双向绑定(bind)还是我必须明确声明 value.two-way ?更改双向绑定(bind)对象的属性有什么问题吗?
提前致谢
最佳答案
很好的问题 - 这里有一些信息:
1) There are two general ways (as I understand) that one can include a web component in a page. These are
<compose>and write a custom element. My question is, coming from Angular there is a big emphasis on scopes (i.e. what is in scope at a specific point in the DOM). I am wondering what is in "scope" (i.e. available to binding expression) within compose and custom elements. I mean, is a parent view-model available within a child template? If so, do child view-model properties hide/shadow the parent view-model properties?
考虑以下标记:
app.html
<template>
<h1>${message}</h1>
<date-picker value.bind="startDate"></date-picker>
<compose view="footer.html"></compose>
<template>
<compose>保留对外部范围的访问。 当模板包含在 footer.html 中时是数据绑定(bind)的,它可以访问任何app.html绑定(bind)到 - 例如,它可以访问 message属性(property)。
自定义元素的模板无法访问外部范围。自定义元素旨在进行封装和移植。因此,不允许他们访问外部范围,从而阻止开发人员创建期望在特定绑定(bind)上下文中使用的自定义元素。从自定义元素中获取数据的主要方式是通过 @bindable。属性(类似于 XAML 中的依赖属性)。
2) In Angular 2, there are guidelines with respect to how data is passed in and out of components. We are not supposed to change non-primitives that are bound to a component (because that forces Angular 2's change detection to always go into that component branch to check all properties).
Are there any guidelines/info to passing data in and out of components in Aurelia? I mean from the reading that I have done it sounds like I would just use
value.bindto bind to all the@bindableproperties. Is that correct?
正确
Are these two-way bound by default or do I have to explicitly declare
value.two-way? Is there anything wrong with changing the properties of a two-way bound object?
Aurelia 自动为输入或选择等内置元素的属性选择正确的默认绑定(bind)模式。如果您想要 one-way 以外的内容,则需要为自定义元素 指定默认值.以下是如何做到这一点:
import {bindingMode} from 'aurelia-framework'; // or 'aurelia-binding';
export class DatePicker {
@bindable({ defaultBindingMode: bindingMode.twoWay }) value; // <----
@bindable min = new Date(1900, 0, 1);
@bindable max = new Date(2250, 11, 31);
...
}
关于javascript - Angular 到 Aurelia 的过渡——一些基本问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35879520/
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
尝试通过RVM将RubyGems升级到版本1.8.10并出现此错误:$rvmrubygemslatestRemovingoldRubygemsfiles...Installingrubygems-1.8.10forruby-1.9.2-p180...ERROR:Errorrunning'GEM_PATH="/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/ruby-1.9.2-p180@global:/Users/foo/.rvm/gems/ruby-1.9.2-p180:/Users/foo/.rvm/gems/rub
我的最终目标是安装当前版本的RubyonRails。我在OSXMountainLion上运行。到目前为止,这是我的过程:已安装的RVM$\curl-Lhttps://get.rvm.io|bash-sstable检查已知(我假设已批准)安装$rvmlistknown我看到当前的稳定版本可用[ruby-]2.0.0[-p247]输入命令安装$rvminstall2.0.0-p247注意:我也试过这些安装命令$rvminstallruby-2.0.0-p247$rvminstallruby=2.0.0-p247我很快就无处可去了。结果:$rvminstall2.0.0-p247Search
由于fast-stemmer的问题,我很难安装我想要的任何rubygem。我把我得到的错误放在下面。Buildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingfast-stemmer:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcreatingMakefilemake"DESTDIR="cleanmake"DESTDIR=
当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub
我正在尝试使用boilerpipe来自JRuby。我看过guide从JRuby调用Java,并成功地将它与另一个Java包一起使用,但无法弄清楚为什么同样的东西不能用于boilerpipe。我正在尝试基本上从JRuby中执行与此Java等效的操作:URLurl=newURL("http://www.example.com/some-location/index.html");Stringtext=ArticleExtractor.INSTANCE.getText(url);在JRuby中试过这个:require'java'url=java.net.URL.new("http://www
我意识到这可能是一个非常基本的问题,但我现在已经花了几天时间回过头来解决这个问题,但出于某种原因,Google就是没有帮助我。(我认为部分问题在于我是一个初学者,我不知道该问什么......)我也看过O'Reilly的RubyCookbook和RailsAPI,但我仍然停留在这个问题上.我找到了一些关于多态关系的信息,但它似乎不是我需要的(尽管如果我错了请告诉我)。我正在尝试调整MichaelHartl'stutorial创建一个包含用户、文章和评论的博客应用程序(不使用脚手架)。我希望评论既属于用户又属于文章。我的主要问题是:我不知道如何将当前文章的ID放入评论Controller。
我正在使用RubyonRails3.0.9,我想生成一个传递一些自定义参数的link_toURL。也就是说,有一个articles_path(www.my_web_site_name.com/articles)我想生成如下内容:link_to'Samplelinktitle',...#HereIshouldimplementthecode#=>'http://www.my_web_site_name.com/articles?param1=value1¶m2=value2&...我如何编写link_to语句“alàRubyonRailsWay”以实现该目的?如果我想通过传递一些
首先回顾一下拉格朗日定理的内容:函数f(x)是在闭区间[a,b]上连续、开区间(a,b)上可导的函数,那么至少存在一个,使得:通过这个表达式我们可以知道,f(x)是函数的主体,a和b可以看作是主体函数f(x)中所取的两个值。那么可以有, 也就意味着我们可以用来替换 这种替换可以用在求某些多项式差的极限中。方法: 外层函数f(x)是一致的,并且h(x)和g(x)是等价无穷小。此时,利用拉格朗日定理,将原式替换为 ,再进行求解,往往会省去复合函数求极限的很多麻烦。使用要注意:1.要先找到主体函数f(x),即外层函数必须相同。2.f(x)找到后,复合部分是等价无穷小。3.要满足作差的形式。如果是加
?博客主页:https://xiaoy.blog.csdn.net?本文由呆呆敲代码的小Y原创,首发于CSDN??学习专栏推荐:Unity系统学习专栏?游戏制作专栏推荐:游戏制作?Unity实战100例专栏推荐:Unity实战100例教程?欢迎点赞?收藏⭐留言?如有错误敬请指正!?未来很长,值得我们全力奔赴更美好的生活✨------------------❤️分割线❤️-------------------------