小編給大家分享一下Angularjs如何自定義一個可輸入的下拉框組件,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
在 angularjs 中自定義一個可輸入的下拉框組件,組件的創建及引入如下。
新建 insertSelect.html 文件
<style type="text/css"> .insert-select { position: relative; } .input-box { position: absolute; height: calc(100% - 4px); width: calc(100% - 25px); top: 2px; left: 2px; padding-left: 10px; outline: none !important; border-radius: 4px !important; border: none !important; } </style> <!--可輸入下拉框--> <div class="insert-select"> <select ng-attr-placeholder="{{placeholder}}" class="form-control" chosen ng-model="modelData" ng-options="item for item in optionList"> <option value=""></option> </select> <input type="text" class="input-box" ng-attr-placeholder="{{placeholder}}" ng-model="modelData"> </div>
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 組件
<insert-select model-data="formData" option-list="successCodeList" placeholder="'請選擇'"> </insert-select>
看完了這篇文章,相信你對“Angularjs如何自定義一個可輸入的下拉框組件”有了一定的了解,如果想了解更多相關知識,歡迎關注創新互聯行業資訊頻道,感謝各位的閱讀!
網站題目:Angularjs如何自定義一個可輸入的下拉框組件-創新互聯
瀏覽地址:http://vcdvsql.cn/article38/isgpp.html
成都網站建設公司_創新互聯,為您提供標簽優化、域名注冊、App開發、App設計、動態網站、外貿建站
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯