JpDevs JpDevs - 1 year ago 85
AngularJS Question

ng-if in select option selected tag

I am developing Angular JS application and I want to make a select option like below.

<select class="form-control" ng-model="rc.status" ng-init="rc.status=1">
<option value="1" selected="selected">Active</option>
<option value="0" selected="">Inactive</option>

I want to make active when the ng-model rc.status becomes 1 and inactive when 0.

How can I do that without doing ng-repeat.

Because I generating this view from laravel and binding the html with Angular js

Answer Source

Here is example that select dropdown value as per rc.status

<script src=""></script>
<div ng-app="">
  <select class="form-control" ng-model="rc.status" ng-init="rc.status=1">
    <option value="--Select--">--Select--</option>
    <option value="1">Active</option>
    <option value="0">Inactive</option>
  <div>Status : {{rc.status}}</div>