假设有以下情况:
App.User = DS.Model.extend({
firstName: DS.attr('string')
});有没有办法确定firstName的类型?
发布于 2013-02-08 09:38:52
我找到了答案:
App.User.metaForProperty('firstName').type发布于 2013-02-08 05:20:55
您可以使用JavaScript的typeof
// Find the type of the first model's firstName.
console.log(typeof userController.objectAt(0).get('firstName'));Ember.JS也有一个内置的typeOf:Ember.typeOf,但在本例中,据我所知,它没有提供任何优势。
https://stackoverflow.com/questions/14760748
复制相似问题