I am trying to use the angularjs drop-down list in the form, and I need to be able to bind the selected item to the model for the new "organization" in my application.
Here is my js module that I use to create all my controls:
var Controls = angular.module('PulseControls', ['ui.bootstrap']); var booleanButtonCtrl = function($scope) { $scope.radioModel = true; }; var currencyDropDownButtonCtrl = function($scope) { $scope.currencies = [{ id: 1, name: 'US Dollar' }, { id: 2, name: 'Euro' }, { id: 3, name: 'Australian Dollar' }]; };
Here is my start code for my CreateNewOrganisation controller
function CreateOrganisationController($scope, $http, $window) { $scope.newOrganisation = { isActive: true, };
and finally here is our html code snippet that includes both "Status" and Currency, both of which use ui-bootstrap ...
<div class="form-group"> <label class="control-label">Status</label><br /> <div ng-controller="booleanButtonCtrl"> <div class="btn-group"> <button type="button" class="btn btn-primary" data-ng-model="newOrganisation.isActive" btn-radio="true"> Active </button> <button type="button" class="btn btn-primary" data-ng-model="newOrganisation.isActive" btn-radio="false"> Dormant </button> </div> </div> </div> <div class="form-group"> <label class="control-label">Currency</label> <div class="dropdown" data-ng-controller="dropDownButtonCtrl"> <div class="btn-group"> <a class="btn btn-primary dropdown-toggle">Please select<span class="caret"></span></a> <ul class="dropdown-menu"> <li ng-repeat="currency in currencies"> <a ng-model = "newOrganisation.currency">{{currency.name}}</a> </li> </ul> </div> </div> </div>
The approach adopted in the status works well, but I can not get the drop-down control for the work of the Currency. Any suggestions?
source share