在 angularjs 中自定义一个可输入的下拉框组件,组件的创建及引入如下。
新建 insertSelect.html 文件
directive 自定义指令
//可输入select框
angular.module("controllers")
.directive("insertSelect", [function () {
return {
restrict: 'AE',
templateUrl: 'template/common/insertSelect.html',
scope: {
modelData: '=modelData',
optionList: '=optionList',
placeholder: '=placeholder', //placeholder 可由引入页面传入
},
link: function ($scope, $elem) {
//
},
controller: ["$scope", function ($scope) {
}]
}
}]);页面引入 insertSelect 组件