I am learning to use reopenClass
method when I was introduced to a property called name
, but when I run the code when an error occurs, the following error message, but I changed the name of another property, but no problem. I find this method of API, we did not see the instructions. I guess the name is not the method reopenClass
reserved keywords?
Error message
ember.debug.js:18772 Uncaught TypeError: Cannot assign to read only property 'name' of function 'function () {
if (!wasApplied) {
Class.proto(); // prepare prototype...
}
if (argume...<omitted>... }'
This is my code
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Ember.js • Guides</title>
<script src="http://cdn.bootcss.com/jquery/2.0.0/jquery.js"></script>
<script src="http://cdn.bootcss.com/ember.js/2.1.0-beta.2/ember.debug.js"></script>
<script src="http://cdn.bootcss.com/ember.js/2.1.0-beta.2/ember.prod.js"></script>
<script type="text/javascript">
MyObject = Ember.Object.extend({
name: 'an object'
});
MyObject.reopenClass({
canBuild: false,
username: 'blog.ddlisting.com'
//Here a bit strange, do not know why you can not use the name for the
// custom property name will prompt this property is self-reading,
//using username no problem! !
,name: 'test'
});
// Gets static property values
console.log(MyObject.canBuild); // false
// For general property values
console.log(MyObject.create().get('name')); // an object
</script>
</head>
<body>
</body>
</html>
I hope you read the description, look forward to your reply. thanks !!