为什么我需要在模板中的所有属性前加上 model.?
Why do I need to prefix all properties in my templates with model.?
要访问模板中的模型 属性 我只是在做:
{{name}}
如 guide
中所述
我现在已经搬到 ember-cli@0.1.12,ember@canary (1.12.0-beta.1+canary.50206d0f),jquery@ 2.1.3,handlebars@2.0.0,不知何故我发现自己被迫在所有属性前加上 model.
。这种情况发生在直接属性上,例如:
{{model.name}}
和绑定属性,例如:
{{view "verifiedEmail" emailBinding="model.email" verifiedBinding="model.isEmailVerified"}}
这是预期的吗?这在哪里记录?这真是一个皮塔饼,因为这意味着我的模板有很多变化。
我记得在某处读到过对象代理已被弃用,但我再也找不到对它的引用了。
显然,这是向 Ember 2.0 (https://github.com/emberjs/rfcs/pull/15)
过渡计划的一部分
Instead of referring to model properties directly (or on this), you will refer to them as model.propName.
Similarly, computed properties that move to your component will need to depend on model.propName if they are migrated from an ObjectController.
In both cases, the short version is that you can no longer rely on the proxying behavior of ObjectController or ArrayController, but you can remedy the situation by prefixing model. to the property name.
The Road to Ember 2.0 的 可路由组件 部分解释了为什么需要进行这些更改。
具体注意点:
In both cases, the short version is that you can no longer rely on the
proxying behavior of ObjectController or ArrayController, but you can
remedy the situation by prefixing model. to the property name.
另请注意,如果您的应用中有很大一部分由于这些更改而需要重构,Ember 核心团队已声明:
We will also provide an optional plugin for Ember 2.0 apps that
restores existing behavior.
所以你可能不需要立即重构,如果太麻烦的话。
要访问模板中的模型 属性 我只是在做:
{{name}}
如 guide
中所述我现在已经搬到 ember-cli@0.1.12,ember@canary (1.12.0-beta.1+canary.50206d0f),jquery@ 2.1.3,handlebars@2.0.0,不知何故我发现自己被迫在所有属性前加上 model.
。这种情况发生在直接属性上,例如:
{{model.name}}
和绑定属性,例如:
{{view "verifiedEmail" emailBinding="model.email" verifiedBinding="model.isEmailVerified"}}
这是预期的吗?这在哪里记录?这真是一个皮塔饼,因为这意味着我的模板有很多变化。
我记得在某处读到过对象代理已被弃用,但我再也找不到对它的引用了。
显然,这是向 Ember 2.0 (https://github.com/emberjs/rfcs/pull/15)
过渡计划的一部分Instead of referring to model properties directly (or on this), you will refer to them as model.propName. Similarly, computed properties that move to your component will need to depend on model.propName if they are migrated from an ObjectController. In both cases, the short version is that you can no longer rely on the proxying behavior of ObjectController or ArrayController, but you can remedy the situation by prefixing model. to the property name.
The Road to Ember 2.0 的 可路由组件 部分解释了为什么需要进行这些更改。
具体注意点:
In both cases, the short version is that you can no longer rely on the proxying behavior of ObjectController or ArrayController, but you can remedy the situation by prefixing model. to the property name.
另请注意,如果您的应用中有很大一部分由于这些更改而需要重构,Ember 核心团队已声明:
We will also provide an optional plugin for Ember 2.0 apps that restores existing behavior.
所以你可能不需要立即重构,如果太麻烦的话。