茄子在线看片免费人成视频,午夜福利精品a在线观看,国产高清自产拍在线观看,久久综合久久狠狠综合

    <s id="ddbnn"></s>
  • <sub id="ddbnn"><ol id="ddbnn"></ol></sub>

  • <legend id="ddbnn"></legend><s id="ddbnn"></s>

    Angularjs material 實現(xiàn)搜索框功能
    來源:易賢網(wǎng) 閱讀:1821 次 日期:2016-07-22 15:35:58
    溫馨提示:易賢網(wǎng)小編為您整理了“Angularjs material 實現(xiàn)搜索框功能”,方便廣大網(wǎng)友查閱!

    這篇文章主要介紹了Angularjs material 實現(xiàn)搜索框功能的相關(guān)資料,需要的朋友可以參考下

    angular-material 是 AngularJS 的一個子項目,用來提供實現(xiàn)了 Material Design 風(fēng)格的組件。

    Material 提供了大量的android 風(fēng)格的UI組件,使用 angularjs + Material 可以很容易開發(fā)出風(fēng)格接近原生 Android 5.x 的web界面。但在實際使用的過程中并不總是能滿足我們的需求。開發(fā)一個組件就成了我們必須學(xué)習(xí)的內(nèi)容。

    下面是一個組件的實現(xiàn):

    //前面省略若干代碼

    directive('mdSearchInput',[function(){

    return{

    restrict:'E',

    controller:['$scope','$timeout',function($scope,$timeout){

    var tsk=null;

    $scope.delay=1000;

    $scope.on_changed=function(){

    if(null !== tsk) {$timeout.cancel(tsk);} //去掉前一個任務(wù)

    tsk = $timeout(function(){

    $timeout.cancel(tsk);tsk=null;

    $scope.onSearch()($scope.searchText);

    },$scope.delay);

    };$scope.on_clear=function(){

    var tsk=null;$scope.searchText='';

    tsk=$timeout(function(){

    $timeout.cancel(tsk);tsk=null;

    $scope.onSearch()($scope.searchText);

    },100);

    }

    }],

    scope:{

    inputName: '@mdInputName',

    searchText: '=?mdSearchText',

    onSearch: '&?mdSearch',

    placeholder: '@placeholder',

    delay: '@delay'

    },

    template:'<div class="md-search-input" layout="row">\

    <input type="text" flex autocomplete="off" ng-model="searchText" name="{{inputName}}" placeholder="{{placeholder}}" ng-change="on_changed()" />\

    <md-button class="md-fab" ng-click="on_clear()" ng-show="searchText!==\'\'"><md-icon md-svg-icon="md-close" style="color:rgba(0,0,0,0.5);"></md-icon></md-button>\

    </div>',

    link:function($scope, $element){

    }

    };

    }]);

    CSS 樣式:

    .md-search-input{

    box-sizing: border-box;border: none;box-shadow: none;background: 0 0; border-radius:5px;background: #FFF;margin:0px;position: relative;

    input{outline: 0;font-size: 14px; width: 100%; padding: 0 15px; line-height: 40px;height: 40px;border: none;background:transparent;}

    button,.md-fab,.md-button,button:hover,.md-fab:hover {

    background:transparent !important;

    line-height:40px;height:40px;width:40px;font-size:14px;box-shadow:none !important;margin:0px;padding:0px;

    color:rgba(0,0,0,0.5) !important;

    }

    }

    配合 ng-route 可以很容易實現(xiàn)無刷新的APP 讓您的web頁面更加接近app體驗

    在 maincontroll中,通過監(jiān)聽 ng-route 的頁面即將跳轉(zhuǎn)事件 來重置消息框

    //在頁面改變之前,重置搜索框.

    $scope.$on('SearchText.Reset',function(){ $scope.searchConfig={show:false, key:'',delay:1200};});

    $rootScope.$on('$routeChangeStart', function (event, next) {

    $rootScope.$broadcast('SearchText.Reset');

    });

    而在需要用到搜索功能的地方,則只需要在控制器里通過如下代碼實現(xiàn):

    //陪值搜索框為己用

    $scope.$emit('Search.Config',{

    show:true, key:'',delay:800,

    emptyText:"請輸入:商家名稱,賬號,電話 等內(nèi)容以進行搜索.",

    onSearch: function(){

    return function(v){

    $scope.merData.query(v); //調(diào)用本控制器的數(shù)據(jù)查詢接口.

    }

    }

    });

    以上所述是小編給大家介紹的Angularjs material 實現(xiàn)搜索框功能,希望對大家有所幫助!

    更多信息請查看網(wǎng)絡(luò)編程
    易賢網(wǎng)手機網(wǎng)站地址:Angularjs material 實現(xiàn)搜索框功能
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2026上岸·考公考編培訓(xùn)報班

    • 報班類型
    • 姓名
    • 手機號
    • 驗證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
    工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報警專用圖標(biāo)