내가 여기에이 튜토리얼에 따라 ChosenJS 플러그인의 각도 지침을 만드는 오전 : https://www.youtube.com/watch?v=8ozyXwLzFYsAngularJS와 + ChosenJS 업데이트 모델
는 내가 뭘 원하는 값을 선택하면 모델 업데이트가 있습니다. 여기
function Foo($scope) {
$scope.legalEntitiesList = [
{ name: 'Foo' },
{ name: 'Bar' }
];
$scope.legalEntity = { name: 'Foo' };
}
myApp.directive('chosen', ['$timeout', function($timeout) {
var linker = function(scope, element, attrs, ngModel) {
if (!ngModel) return;
element.addClass('chzn-select');
$(element).chosen()
.change(function(e) {
console.log(ngModel.$viewValue);
});
scope.$watch(attrs.chosen, function() {
$(element).trigger('liszt:updated');
});
}
return {
restrict: 'A',
scope: true,
require: '?ngModel',
link: linker
}
}]);
는 바이올린입니다 :
http://jsfiddle.net/dkrotts/MQzXq/7/. 다른 옵션을 선택하면 모델 값이 업데이트되지 않습니다.