angularjs select without ng-options or static options

Adilson Santos da Rocha picture Adilson Santos da Rocha · Aug 11, 2015 · Viewed 9.8k times · Source

How, to use a static select in angularjs.

I wanna create a select ng-model with change event with statc values.

<form ng-controller="mycontroller">
    <select class="form-control"  name='modelid' ng-model="modelid"  ng-change="modelidchange">
        <option value="-1">select </option>       
        <option value='4'>Static text 4</option>
        <option value='1'>Static text 1</option>
        <option value='2'>Static text 2</option>                 
    </select>
</form>

my controller:

angular.module('app').controller('chapter',function($scope,$http) {
    console.log('ok')
    $scope.id = modelid
    alert($scope.id)
});

I just wanna get de model value, but this error:

Error: ngOptions:iexp
Invalid Expression

I DON'T WANNA USE NG-OPTIONS just a static select.

Can somebody help me ?

Answer

macrog picture macrog · Aug 11, 2015

check this jsfiddle link, maybe it will help

<select ng-model="filterCondition.operator">
    <option ng-selected="{{operator.value == filterCondition.operator}}" ng-repeat="operator in operators" value="{{operator.value}}">{{operator.displayName}}</option>

and this answer