I am currently developing a project with AngularJS and I need to display the selected value. To achieve this, I am utilizing the chosen filter available at:
https://github.com/leocaseiro/angular-chosen
Below is the code snippet that I have implemented:
.directive('chooseCustomer', function($timeout) {
var linker = function(scope, element, attr) {
scope.$watch('customerInfo', function() {
$timeout(function() {
element.trigger('chosen:updated');
}, 0, false);
}, true);
$timeout(function() {
element.chosen();
}, 0, false);
};
return {
restrict: 'A',
link: linker
};
})
In my controller:
$scope.assCustomers.customerName = companyName //displaying company name here
In the HTML file:
<select class="selectbox_menulist" required name="customerName" choose-customer="" ng-options="customer['company-name'] for customer in customerInfo"
ng-model="assCustomers.customerName" ng-change="getBillingNumber()" ng-disabled="promoAssociation" data-placeholder="Please Select">