ngOfficeUIFabric / ng-officeuifabric

Office UI Fabric (https://github.com/OfficeDev/office-ui-fabric) implementation for Angular
http://ngOfficeUiFabric.com
MIT License
321 stars 67 forks source link

Set ngofficeuifabric dropdown selected value dynamically #407

Closed johnnyongesa closed 8 years ago

johnnyongesa commented 8 years ago

Hi I have following dropdown

<div class="ms-Dropdown " tabindex="0">
            <label class="ms-Label is-required">Sub-process</label>
           <div ng-controller="SubProcessController" id="SubProcessController">
  <uif-dropdown ng-model="SubProcessNG" selected-title="SOD">
    <uif-dropdown-option ng-repeat="x in options" value="{{x.id}}" ng-selected="{{ x.Selected == true }}">{{x.value}}</uif-dropdown-option>   
  </uif-dropdown>
     <span class="ms-Dropdown-description ms-fontColor-red" id="SubProcessDescription"></span>
           <span id="SubProcess" style=" display: none"  >{{SubProcessNG}}</span> 
          </div></div>

and the following angularjs code

 var demoApp = angular.module('demoApp', [
             'officeuifabric.core',
             'officeuifabric.components.dropdown'
        ]);
        demoApp.controller('SubProcessController', ['$scope', SubProcessController]);
  function SubProcessController($scope) {
                $scope.options = [];
                $scope.updateDropdown = function (data) {
                    $scope.options = data;
                };
                $scope.selectedItemvalue = "1";

            }
function **setDropdownvalue**(){
**//set dropdown code**
}

how do i set dropdown value from the function setDropdownvalue above

ghost commented 8 years ago

Just set the value of the variable of your ng-model : SubProcessNG

johnnyongesa commented 8 years ago

Do you mean just the function below is enough;

function **setDropdownvalue**(newValue){
SubProcessNG=newValue;
}
ghost commented 8 years ago

Sorry, but this is not a support forum. This is a very basic angular question. If you had tried your code you would have found it is indeed working like that.