Open
Description
Hello!
I use ngrx to save my array, and read from it,
But how i understand, sortablejs + ngrx its nor good idea.
If i wanna change array in ngrx i first need dispatch action, but sortablejs try splice this arrays and i take erorr this.target.splice is not a function
component
export class HomeComponent implements OnInit {
console = console;
todos$: Observable<any>;
todo: string;
todoDate: string;
editing = false;
indexToEdit: number | null;
currentTime = new Date();
constructor(private store: Store<any>) {}
ngOnInit() {
this.todos$ = this.store.select('todoReducer');
}
}
template
<ul class="todo-list" [sortablejs]="todos$">
<li class="todo"
*ngFor="let todo of todos$ | async; let i = index;"
[ngClass]="{'todo--done': todo.done, 'todo--is-over': todo.date < currentTime, 'todo--close-date': todo.date.getDate() - currentTime.getDate() <= 3 && todo.date > currentTime}"
>
<div class="todo__checkbox" (click)="toggleDone(todo, i)">
<i class="fa"
[ngClass]="{'fa-check-square': todo.done, 'fa-square-o': !todo.done}"
aria-hidden="true">
</i>
</div>
<span class="todo__name">{{ todo.value }}</span>
<span class="todo__date">{{todo.stringDate}}</span>
<div class="todo__btns">
<button (click)="editTodo(todo, i)"><i class="fa fa-pencil" aria-hidden="true"></i></button>
<button (click)="deleteTodo(i)"><i class="fa fa-trash" aria-hidden="true"></i></button>
</div>
</li>
</ul>