Я создаю проект, используя angularjs. Я хочу показать выбранное значение. Я использую выбранный фильтр:
https://github.com/leocaseiro/angular-chosen
Вот мой код:
.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
};
})
В контроллере:
$scope.assCustmoers.customerName = companyName //here is compony name show
В html:
<select class="selectbox_menulist" required name="customerName" choose-customer = "" ng-options="customer['company-name'] for customer in customerInfo" ng-model="assCustmoers.customerName" ng-change="getBillingNumber()" ng-disabled="promoAsscoiation" data-placeholder="Please Select">
На самом деле проблема с моделью, значением модели не обновляется
.directive('chooseCustomer', function($timeout) {
var linker = function(scope, element, attr) {
scope.$watch('assCustmoers.customerName', function() {
$timeout(function() {
element.trigger('chosen:updated');
}, 0, false);
}, true);
scope.$watch('customerInfo', function() {
$timeout(function() {
element.trigger('chosen:updated');
}, 0, false);
}, true);
$timeout(function() {
element.chosen();
}, 0, false);
};
return {
restrict: 'A',
link: linker
};
})