0

I am using angular-cli and bootstrap-colorpicker. I want to get the value while picking up a color from the colorpicker onchange / oninput method.

here is my html code:

<div id="cp2" class="input-group colorpicker-component">
  <input id="colorInput" type="text" value="#00AABB" class="form-control textedit" data-type="color"  (input)="testevent($event)" />
  <span class="input-group-addon"><i></i></span>
</div>

in ts file:

testevent(event){
    console.log(event.target.value);
}

This function works when I make an input directly in the input type. Using jQuery method onchange or oninput I am able to get value. But I want to use angular2 way.

Please suggest me to solve this situation.

Thanks and Regards

1 Answer 1

0

You can use [(ngModel)] just as anyother input

  <input id="colorInput" type="text" 
     [(ngModel)]="colorCode" 
      value="#00AABB" 
      class="form-control textedit" 
      data-type="color"  (change)="test()" />


test(){
    console.log(this.colorCode);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.