質問

Should attributes in a model all start with a lowercase letter?

Recently I ran into the issue of having attributes in the model that start with an uppercase letter not work with the "valueBinding=UppercaseAttribute" quality in Ember Handlebars.

I have a huge amount of attributes that are going to be changed in the future and I'm wondering if I should just get into the habit of changing them to lowercase now and saving myself a lot of work.

And now the code for all of you visual learners.

So it's this (uppercase)

VpcYeoman.Category = DS.Model.extend({
    RecordCategoryID:DS.attr('number'),
    Name: DS.attr('string'),
});

VS

This (lowercase)

VpcYeoman.Category = DS.Model.extend({
    recordCategoryID:DS.attr('number'),
    name: DS.attr('string')
});

Thanks for the help!

役に立ちましたか?

解決

Yes. By convention, all variable names in most languages should be in camel-case, starting with a lowercase character. Javascript adheres to this convention.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top