angularJS如何實(shí)現(xiàn)模態(tài)框$modal

小編給大家分享一下angularJS如何實(shí)現(xiàn)模態(tài)框$modal,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!

創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),綏濱企業(yè)網(wǎng)站建設(shè),綏濱品牌網(wǎng)站建設(shè),網(wǎng)站定制,綏濱網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,綏濱網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

1.引入$modal模塊

如:angular.module('ModalCtrl',['$modal' ,'$scope' , function($modal ,$scope ){ }]);

2.執(zhí)行調(diào)模態(tài)框 函數(shù)

$scope.editModule = function(type, size, id) { 
  $scope.id = id; 
  var modalInstance = $modal.open({ 
    templateUrl: 'tpl/weichat_modulebaseinfo.html', //template:'html元素模板', 
    controller: 'EditModuleCtrl', // 初始化模態(tài)范圍 
    size: size, //大小配置 
    scope: '一個(gè)作用域?yàn)槟B(tài)的內(nèi)容使用($modal會(huì)創(chuàng)建一個(gè)當(dāng)前作用域的子作用域,scope可有可無)默認(rèn)為$rootScope', 
    resolve: { 
      items: function() { 
        return $scope.id; //向模態(tài)框控制器中傳值 
      } 
    } 
    background: '', //控制背景,true(有) or false(無),static背景存在,但是點(diǎn)擊模態(tài)窗口之外,模態(tài)窗不關(guān)閉 
    keyboard: '', //按下Esc時(shí),模態(tài)對(duì)話框是否關(guān)閉,默認(rèn)為ture 
    windowClass: '' //指定一個(gè)class并被添加到模態(tài)窗口中 
 
  }); 
 
  modalInstance.result.then(function(selectedItem) { //模態(tài)框關(guān)閉后返回函數(shù),selectedItem為返回值 
 
  }) 
}

3.創(chuàng)建模態(tài)框控制器

app.controller('EditModuleCtrl', ['$scope', '$modalInstance', 'BookService', '$stateParams', 'items', function($scope, $modalInstance, BookService, $stateParams, items) { //依賴于modalInstance 
    //items為傳過來的值 
    $scope.modalBack = function() { 
      //執(zhí)行模態(tài)框內(nèi)部操作 
    } 
 
    $scope.ok = function() { 
      $modalInstance.close($scope.textid); //關(guān)閉并返回當(dāng)前選項(xiàng) 
    }; 
    $scope.cancel = function() { 
      $modalInstance.dismiss('cancel'); // 退出不執(zhí)行任何操作 
    } 
  }])

以上是“angularJS如何實(shí)現(xiàn)模態(tài)框$modal”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

新聞名稱:angularJS如何實(shí)現(xiàn)模態(tài)框$modal
網(wǎng)頁鏈接:http://www.muchs.cn/article22/geejcc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、域名注冊(cè)、定制網(wǎng)站、小程序開發(fā)、用戶體驗(yàn)Google

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設(shè)網(wǎng)站維護(hù)公司