Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/444.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 余烬反射联想_Javascript_Ember.js - Fatal编程技术网

Javascript 余烬反射联想

Javascript 余烬反射联想,javascript,ember.js,Javascript,Ember.js,我试图实现“跟随者/跟随者”关系 app/templates/users.hbs--------------------------- {{#each model as |user|}} ... <button {{action 'follow' user}}>Follow</button> {{/each}} follow(user){ //currentUser is the one clicking on 'follow' button

我试图实现“跟随者/跟随者”关系

app/templates/users.hbs---------------------------

{{#each model as |user|}}
   ...
  <button {{action 'follow' user}}>Follow</button>
{{/each}}
 follow(user){
   //currentUser is the one clicking on 'follow' button 
   //and it works.I can successfully alert it's properties.
   currentUser.get('followings').pushObject(user);
 },
...
followings: DS.hasMany('user',{inverse: null}),
followers: DS.hasMany('user',{inverse: null}),
app/models/user.js-----------------------

{{#each model as |user|}}
   ...
  <button {{action 'follow' user}}>Follow</button>
{{/each}}
 follow(user){
   //currentUser is the one clicking on 'follow' button 
   //and it works.I can successfully alert it's properties.
   currentUser.get('followings').pushObject(user);
 },
...
followings: DS.hasMany('user',{inverse: null}),
followers: DS.hasMany('user',{inverse: null}),
现在,这个解决方案导致了下面的错误

Uncaught TypeError: Cannot read the property 'modelName' of undefined at assertPolymorphicType.notifyRecordRelationshipAdded
试试这个:

followings: DS.hasMany('user', { inverse: 'followers' },
followers: DS.hasMany('user', { inverse: 'followings' },
试试这个:

followings: DS.hasMany('user', { inverse: 'followers' },
followers: DS.hasMany('user', { inverse: 'followings' },