我已经参考这个链接在 Angular.js 中实现了选择的插件
我能够获取该值,现在我想要在所选下拉列表中预先选择所选值。
谁能告诉我这样做的简单方法。示例代码:
<select name="SelectedName" id="SelectedName" data-placeholder="Choose a Name..." chosen
ng-model="Info.SelectedNameModel"
ng-options="jd.Name for jd in Info.List"
class="form-control chosen-select"></select>
在 Js 代码中
.directive('chosen', function() {
var linker = function (scope, element, attr) {
// update the select when data is loaded
scope.$watch('Info.List', function (oldVal, newVal) {
element.trigger('chosen:updated');
});
element.chosen();
};
return {
restrict: 'A',
link: linker
};
});
样品清单: {"Name":"PQR"},{"Name":"LMN"}
在数据库中,我将唯一的值存储为“LMN”
因此,当下拉加载我想显示为 LMN 选择。
让我知道是否有人已经这样做了。