【发布时间】:2013-10-26 15:23:33
【问题描述】:
我正在尝试为 bootstrap-select 创建一个指令:
http://silviomoreto.github.io/bootstrap-select/(它允许创建漂亮的选择)
根据以下教程,将 jquery 插件转换为 angular 指令应该很容易:http://www.youtube.com/watch?v=9Bu73oQQSio 但事实上,目前我还没有停留在第一步,我无法让最基本的功能正常工作。我尝试了不同的方法:
<select multiple selectpicker>
<option selectpickeroption ng-repeat="MyModel in MyModels">
{{ MyModel.MyProperty }}
</option>
</select>
<selectpicker multiple="multiple">
<option ng-repeat="MyModel in MyModels">
{{ MyModel.MyProperty }}
</option>
</selectpicker>
一起
Application.directive('selectpicker', [function () {
return {
restrict: 'A',
compile: function() {
return function(scope, element, attributes, controller) {
element.selectpicker(); // launch `.selectpicker()` plugin
// Lunching selectpicker at current point is way to early,
// at this point all <option ng-repeat="MyModel in MyModels">..</option>
// contain the following text `{{ MyModel.MyProperty }}`
};
}
};
}]);
但它们都不起作用,它只是不想集成到 Angular 中。有没有一种简单的方法可以以最小的努力将这个简单的插件包装成角度?因为我花了半天时间试图让它工作
:(
【问题讨论】:
标签: jquery angularjs bootstrap-select