문제

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