Ich fange gerade an, Typoskript mit dem Aurelia Rahmenwerk zu lernen. Ich habe Matthew Davis Blog TypeScript Enums in Aurelia Templates mit ViewEngineHooks http://davismj.me/blog/template-constants/ in die Aurelia Todo App implementiert.Typoskript enum Standardwert
Ich möchte bitte den Standardaufzählungswert auf den 2. Wert in der Liste setzen und den Standardwert auf den 1. Wert in der Liste setzen.
Auch möchte ich bitte gerne wissen, ob {Todo, Priorität} oder {} Todo muss den Import in dem To-do-list.ts wie gezeigt
todo.ts
// Pro Tip: By starting our enum at 1, we ensure that all values in the enum are truthy.
export enum Priority {
High = 1,
Medium,
Low
}
export class Todo {
@observable done;
//*** Setting priority: Priority = 2 OR priority: Priority = Priority.Medium - Does not change the default from High/1 ***
//constructor(public list: TodoList, public description: string, public priority: Priority = 2, public editing: boolean = false) {
constructor(public list: TodoList, public description: string, public priority: Priority = Priority.Medium, public editing: boolean = false) {
this.list = list;
this.description = description;
//*** Setting this.priority = 2 OR this.priority = Priority.Medium - Does not change the default from High/1 ;
//this.priority = 2;
this.priority = Priority.Medium;
this.editing = false;
}
todo-Liste .ts
//*** Is {Todo} OR {Todo, Priority} needed for importing? ***
//import {Todo} from './todo';
import {Todo, Priority} from './todo';
...
add(description) {
if (description) {
//*** Setting (this, description, 2) OR (this, description, Priority.Medium) - Does not change the default from High/1 ***
//this.todos.push(new Todo(this, description, 2));
this.todos.push(new Todo(this, description, Priority.Medium));
this.invalidateView();
}
}
todo.html
<select id="priority" value.bind="type">
<option value.bind="Priority[type]" repeat.for="type of Prioritys">${type}</option>
</select>
Es gab einen Tippfehler in meinem Blog, danke, dass Sie mir geholfen haben, es zu finden –