【发布时间】:2015-09-18 17:18:52
【问题描述】:
我有一个指令应该让我的选择更有趣:
angular.module('myDeadLine')
.directive('dcSelect', function () {
return {
restrict: 'E',
scope: {
label: '@',
ngModel: '=',
ngOptions: '=',...
},
transclude: true,
templateUrl: '/web/_utils/dcselect/dcselect.html'
};
});
使用模板:
<div class="form-group">
<select class="form-control"
ng-focus="dcSelectFocused=true"
ng-blur="dcSelectFocused=false">
<option value="">{{label}}</option>
</select>
<i class="fa fa-arrow-down" ng-class="{ 'open': dcSelectFocused }"></i>
</div>
将所有与选择相关的属性分配给选择标签的最简单方法是什么,以便我可以像这样使用它:
<dc-select label="Select something" ng-model="model" ng-options="" and so on></dc-select>
有没有一种自动化的方式可以让我将所有属性转移到“标签”之外的选择,并让它们发挥作用?
【问题讨论】:
-
你可以看到关于
require
标签: javascript angularjs angularjs-directive