0

I have predefined scope values:

$scope.synchronizationStates =
                            [
                                true,
                                false
                            ];

And i have defined select:

<select class="form-control"  data-ng-model="projectDetail.synced" data-ng-options="synced for synchronizationState in projectDetail.synchronized">
</select>

I would like to have for state false display preselected value "NOT_SYNCED" and for true "SYNCED" And also change state value if value is changed by user.

How can I do it please using AngularJs?

Thanks for any advice.

2 Answers 2

1

In controller use :

 $scope.synchronizationStates  = [
    {text:'not synced',value:false},
    {text:'synced',value:true},
    ]

and in html

<select ng-model="selected" ng-options="value.value as value.text for value in synchronizationStates"></select>

working plunker here a link!

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

Comments

0

I think its better for you to use something like this

    ng-options="e as e for e in synchronizationStates "></select>

and maybe make each element in the array an object with string for the name and true or false for the value

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.