How to declare the item controller in an array controller - ember.js -


I am trying to write the Todo app (using amber-CLI). When I added active and complete paths under my todos resource, my item controller stopped working before setting up my object controller before using the item controller in my array controller.

router.js

  import 'amber' from amber; Var Router = Amber Rotor.extended ({place: todomcnaw.location.tep}); Router.map (function () (this.resource ('todos', {path: '/'}, function () {this.route ('active'); this.route ('full');}); ); Export the default router;  Import from Amber;   

Controller / todos.js

  Import from Amber; Var TodosController = Ember Get the Todo title set by .rrayController.extend ({actions: {createTodo: function () {// "New Toado" text field var title = this.get ('newTitle'); // Create new Todo model var todo = This.store.createRecord ('todo', {title: title, iscompleted: false}); // clear the "new tabo" text field this.set ('newTit Le ',' '); / / Save new model todo.save ();}}, item controller:' todo ', allAreDone: function (key, value) {if (value === undefined) {return.get ( 'Length')> & amp; amp; amp; amp; amp; amp; amp; amp ;; this.everyProperty ('iscompleted', true); else {this.setEach ('iscompleted', value); This.invoke ('save'); return value;}} .property ('@ every' (full ')' gt; fully: function () {return.filterBy ('iscompleted' is true). ('Length');} .property ('@ each.iscompleted'), remaining: function () {return.filterBy ('iscompleted', false) .get ('length');} .property ('@ Each. Iscompleted '), inflec Tion: function () {var balance = this.get (' left '); Return (balance === 1)? 'Item': 'item'; } .property ('left')}); Export Default TodosController; Import from Amber;   

Controller / todo.js

  Import from Amber; Var TodoController = Ember.ObjectController.extend ({actions: {editTodo: function () {this.set ('isEditing' is true);} Accept change: function () {// Remove this property by editing If the Todo is empty then remove it // Save it with a new title if (amber.it ('model.title')). {This.send ('removeTodo');} Else {this.get ('model'). Save ();}}, extract: function () {var todo = this.get ('model'); todo.deleteRecord (); Todo.save ();}}}); Export TodoController Default;   

Before I add my nested routes, works in todo.js, now when I try to take any action in todo.js, then I have a console Get the following:

  Unwanted error: nothing handles the 'editoda' operation. If you have handled the operation, then this error may be due to returning right from the action handler in an administrator, which may cause bubbles to take action.   

Adding templates below the comments ....

template / todos.hbs

  {{input type = "text" Id = "new-todo" placeholder = "what should be done?" Value = newTitle action = "createTodo"}} {{outlet}} & lt; Footer id = "footer" & gt; & Lt; Span id = "todo-count" & gt; & Lt; Strong> {{}} Balance & lt; / Strong> {{Inflection}} left & lt; / Span & gt; & Lt; Ul id = "filter" & gt; & Lt; Li & gt; {{# Link-to "todos.index" activeClass = "selected"}} All {{/ link-to}} & lt; / Li & gt; & Lt; Li & gt; {{# Link-to "todos.active" activeClass = "selected"}} Active {{/ link-to}} & lt; / Li & gt; & Lt; Li & gt; {{# Link-to "todos.complete" activeClass = "selected"}} Active {{/ link-to}} & lt; / Li & gt; & Lt; / Ul & gt; & Lt; Button ID = "Clear" & gt; Full (1) & lt; / Button & gt; Clear & lt; / Footer & gt;   

Templates / todos / index.hbs

  & lt; Section id = "main" & gt; & Lt; Ul id = "Tudo-list" & gt; {{#each}} & lt; Li {{bind-entry class = "hash: full done editing: editing"}} & gt; {{Input type = "text" class = "edit" value = title = focus-out = "acceptable change" insert -newline = "acceptable change"}} {{else}} {{input type = "{{title} } & Lt; / label & gt; Checkbox "check = isgroup =" toggle "}} & lt; Label {{action "editTodo" = "DoubleClick"}} & lt; Button {{Action "Delete")} class = "destroyed" & gt; & Lt; / Button & gt; {{/ If}} & lt; / Li & gt; {{/ Every}} & lt; / Ul & gt; & Lt; / Section & gt;    

Change your template to:

  { {{{/}} {{/ Each}}   

I blocked the block due to changes in block and reference due to updates in {{amber 1.6.0.

I would like to add more markup to templates in this way for other deviors so that they can quickly recognize what is going on without opening the root controller in javascript.

If you decide to set some #sortproperties on the array controller, then you can also change the "content" with "organized content".

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -