0

I am using Angular version 2.0.0. I have a menu with a list of choices, and I want to set the default one explicitly and also if any option is changed, I want to know which one was changed by using two way data binding.

I have this in my html

<select [(ng-model)]="cosResponse.systemSelection.selected" (ng-model-change)="onChange(cosResponse.systemSelection.shouldRefresh)">

but then in the browser, I get this error: Can't bind to 'ng-model' since it isn't a known property of 'select' It isn't a problem with importing FormsModule or ReactiveFormsModule since my other elements like a checkbox, etc work fine with [(ng-model)]. It is only the select that is not working with two way data binding.

1 Answer 1

2

You should be using camelCase. E.g.,

<select 
  [(ngModel)]="cosResponse.systemSelection.selected"
  (ngModelChange)="onChange(cosResponse.systemSelection.shouldRefresh)">

See docs.

Sign up to request clarification or add additional context in comments.

1 Comment

Oops missed that out.. I guess I copied that over from angular1 docs and didn't realize the typo. Thanks.

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.