Action handlers implemented directly on controllers are deprecated -how to correct this?

前端 未结 2 862
忘掉有多难
忘掉有多难 2021-02-12 20:32

I just upgraded from ember.js RC7 to RC8 and found that a simple template (shown below) would throw a deprecated warning

\"Action handlers implemented di

2条回答
  •  旧时难觅i
    2021-02-12 21:03

    It looks like I just needed to give the PR a look that changed this :)

    In my controller I just needed to move the addPerson / deletePerson under actions like so

    App.PeopleController = Ember.ArrayController.extend({                                                                  
        actions: {                                                                                                         
            addPerson: function() {                                                                                        
                var person = {                                                                                             
                    firstName: this.get('firstName'),                                                                      
                    lastName: this.get('lastName')                                                                         
                };                                                                                                         
                App.Person.add(person);                                                                                    
            },                                                                                                             
            deletePerson: function(person) {                                                                               
                App.Person.remove(person);                                                                                 
            }                                                                                                              
        }                                                                                                                  
    });
    

提交回复
热议问题