0

enter image description here

Above is template i am note able to set note.color=color.color and update note how can we do

Below is html code how note is unable to update as color change:::

<div class="card card-1" *ngFor="let note of notes" style="background:note.color">
    <div style=" background:note.color;margin10px ">
        <img [src]="pinImg" alt='Pin' (click)="pinUnpin(note,true)" />

        <mat-form-field>
            <input contenteditable="true" matInput [(ngModel)]="note.title">
        </mat-form-field>

        <mat-form-field>
            <input contenteditable="true" matInput [(ngModel)]="note.body">
        </mat-form-field>
        <br>
        <div>

            <img [src]="archiveImg" alt='Archive' (click)="archiveUnarchive(note,true)" />
            <img style="width: 15px" [src]="trashImg" alt='Archive' (click)="trashUntrash(note,true)" />
            <ng2-dropdown>
                <ng2-dropdown-button>
                    <img [src]="colorPalet" alt='color palete' />
                </ng2-dropdown-button>
                <ng2-dropdown-menu>
                    <ng2-menu-item *ngFor="let color of colors">

                        <a (click)="updateNote(note)">
                            <img src="{{color.path}}" alt="{{color.color}}" (click)="note.color=color.color ; updateNote(note)" />
                            <!-- click="note.color=color.color" -->
                        </a>
                    </ng2-menu-item>
                </ng2-dropdown-menu>
            </ng2-dropdown>
            <button mat-button class="donebtn" style="width:100px" (click)="updateNote(note)">DONE</button>
        </div>
    </div>
</div>

above is html code how note is unable to update as color change:::

Sanoj_V
  • 2,936
  • 1
  • 12
  • 28
Ragini Patil
  • 109
  • 1
  • 13
  • 1
    use a method instead. what error you are getting? suggessting you to add code instead of screenshot. – Aravind Jan 15 '18 at 09:52
  • we don't like your screenshot. please show your code instead screenshot – Imran Jan 15 '18 at 09:55
  • @Aravind i am not getting any error.. I want to set note color and then update that note ;also i wanted to set note background color .. – Ragini Patil Jan 15 '18 at 10:50

2 Answers2

1

Don't need two click methods for same node

Your question is not clear. But I think it's conflicted your two click methods Try:

<a (click)="note.color=color.color ; updateNote(note)">
   <img src="{{color.path}}" alt="{{color.color}}"  
<a/>

Note: make sure that you don't update color value in your updateNote() method

Imran
  • 3,031
  • 4
  • 25
  • 41
1

[style.background]="note.color" ---> to set background color of card/note

To set note.color:::

<a (click)="updateNote(note)">
    <img src="{{color.path}}" alt="{{color.color}}" (click)="note.color=color.color " />
</a>
Sanoj_V
  • 2,936
  • 1
  • 12
  • 28
Ragini Patil
  • 109
  • 1
  • 13