jeudi 15 octobre 2015

observer fire action to early. before action is initialize observes fired the action

Template

<script type="text/x-handlebars">
  <h2>Welcome to Ember.js</h2>
    {{outlet}}
</script>

<script type="text/x-handlebars" data-template-name="index">
  <ul>
   {{input type="text" value=model.name}}
  </ul>
  <p {{action 'test'}}>test</p>
</script>

ember code

App = Ember.Application.create();

App.Router.map(function () {
// put your routes here
});

App.IndexRoute = Ember.Route.extend({
  model: function () {
    return Ember.Object.create({name:'dilip'});
  },
  actions:{
    test:function(){
        alert('route test');
        console.log('test')
  }
}
});

App.IndexController = Ember.Controller.extend({
  handleChange:function()
  {
    console.log('handle')
    this.send('test')

  }.observes('model.name')
})

I have written action 'test' but its showing below error. only this error comming while i am using observes.

Error while loading route: Error: Nothing handled the action 'test'.

Aucun commentaire:

Enregistrer un commentaire