Binson Eldhose Binson Eldhose - 1 year ago 90
AngularJS Question

ng-model is not updating in select (ng-options)

I need to bind an array into select control and save the selected option to another variable . Please check this plunker code for whole problem and code

$scope.actions = [{ name: "alert", id: 1 }, { name: "drop", id: 2 }];
$scope.raction = $scope.actions[0]; // Keeping first element to model

<select class="form-control"
ng-model="raction" ng-options=" for action in actions" ></select>

Answer Source

Problem is in your scope binding. Change your code like this:

$scope.showit = function() {

This was an angular-strap issue, you can read more here :

A new scope is created regardless of the scope passed in. Variables assigned to the scope in the controller will be visible using the $parent variable.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download