最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

AngularJS中使用ngModal模態(tài)框?qū)嵗?/h1>
 更新時(shí)間:2017年05月27日 10:37:44   作者:?jiǎn)鑶鑶枥怖怖? 
本篇文章主要介紹了AngularJS中使用ngModal模態(tài)框?qū)嵗【幱X(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

在AngularJS中使用模態(tài)框需要引用的文件:

  1. angular.js 1.5.5
  2. ui.bootstrap-tpls.js 0.11.2
  3. bootstrap.css 3.3.7

需要注意版本要一致,高版本的不支持這種方法,會(huì)出錯(cuò)

將需要彈出的模態(tài)框的內(nèi)容寫(xiě)在 script 標(biāo)簽中,指明屬性,放在頁(yè)面中

<script type="text/ng-template" id="modal.html"> 
<div>
  <div class="modal-header">
    <h3 class="modal-title" align="center">
      標(biāo)題信息
    </h3>
  </div>
  <div class="modal-body">
    <div align="center">
      模態(tài)框內(nèi)容
    </div>
  </div>
  <div class="modal-footer">
    <button class="btn btn-primary" ng-click="ok()">
      確認(rèn)
    </button>
    <button class="btn btn-warning" ng-click="cancel()">
      退出
    </button>
  </div>
</div>
</script>

在App和Controller中注入模態(tài)框

var app = angular.module('app', ['ui.bootstrap']);
app.controller('modalController', function($scope, $rootScope,$modal) {
  $scope.openModel = function() {
      var modalInstance = $modal.open({
        templateUrl : 'modal.html',//script標(biāo)簽中定義的id
        controller : 'modalCtrl',//modal對(duì)應(yīng)的Controller
        resolve : {
          data : function() {//data作為modal的controller傳入的參數(shù)
             return data;//用于傳遞數(shù)據(jù)
          }
        }
      })
    }
}

//模態(tài)框?qū)?yīng)的Controller
app.controller('modalCtrl', function($scope, $modalInstance, data) {
  $scope.data= data;

  //在這里處理要進(jìn)行的操作  
  $scope.ok = function() {
    $modalInstance.close();
  };
  $scope.cancel = function() {
    $modalInstance.dismiss('cancel');
  }
});

添加事件觸發(fā)顯示模態(tài)框

<button ng-click="openModal()">打開(kāi)模態(tài)框</button>

html

<!DOCTYPE html>
<html ng-app="app" ng-controller="modalController">
<head>
  <title>ng-model模態(tài)框</title>
</head>
<link  rel="external nofollow" rel="stylesheet">
<body>
<button ng-click="openModal()">打開(kāi)模態(tài)框</button>

<script type="text/ng-template" id="modal.html"> 
  <div>
    <div class="modal-header">
      <h3 class="modal-title" align="center">
        標(biāo)題信息
      </h3>
    </div>
    <div class="modal-body">
      <div align="center">
        模態(tài)框內(nèi)容 <br>
        {{data}}
      </div>
    </div>
    <div class="modal-footer">
      <button class="btn btn-primary" ng-click="ok()">
        確認(rèn)
      </button>
      <button class="btn btn-warning" ng-click="cancel()">
        退出
      </button>
    </div>
  </div>
</script>

<script src="https://cdn.bootcss.com/angular.js/1.5.5/angular.min.js"></script>
<script src="https://cdn.bootcss.com/angular-ui-bootstrap/0.11.2/ui-bootstrap-tpls.min.js"></script>

<script type="text/javascript">
  var app = angular.module('app', ['ui.bootstrap']);
  app.controller('modalController', function($scope, $rootScope, $modal) {
    var data = "通過(guò)modal傳遞的數(shù)據(jù)";
    $scope.openModal = function() {
        var modalInstance = $modal.open({
          templateUrl : 'modal.html',//script標(biāo)簽中定義的id
          controller : 'modalCtrl',//modal對(duì)應(yīng)的Controller
          resolve : {
            data : function() {//data作為modal的controller傳入的參數(shù)
               return data;//用于傳遞數(shù)據(jù)
            }
          }
        })
      }
  })
   //模態(tài)框?qū)?yīng)的Controller
   app.controller('modalCtrl', function($scope, $modalInstance, data) {
     $scope.data= data;

     //在這里處理要進(jìn)行的操作
     $scope.ok = function() {
       $modalInstance.close();
     };
     $scope.cancel = function() {
       $modalInstance.dismiss('cancel');
     }
  });
</script>
</body>
</html>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • angular.js分頁(yè)代碼的實(shí)例

    angular.js分頁(yè)代碼的實(shí)例

    本文用實(shí)例詳細(xì)給大家展示了angular.js分頁(yè)代碼,代碼很詳細(xì),感興趣的小伙伴們可以參考一下
    2016-07-07
  • Angularjs自定義指令Directive詳解

    Angularjs自定義指令Directive詳解

    Directive是一個(gè)非常棒的功能??梢詫?shí)現(xiàn)我們自義的的功能方法。下面通過(guò)實(shí)例代碼給大家介紹Angularjs自定義指令Directive相關(guān)知識(shí),感興趣的朋友一起學(xué)習(xí)吧
    2017-05-05
  • Angular本地存儲(chǔ)安全分析詳解

    Angular本地存儲(chǔ)安全分析詳解

    這篇文章主要為大家介紹了Angular本地存儲(chǔ)安全分析詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-03-03
  • AngularJS實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)后自動(dòng)彈出對(duì)話(huà)框?qū)嵗a

    AngularJS實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)后自動(dòng)彈出對(duì)話(huà)框?qū)嵗a

    這篇文章主要介紹了AngularJS實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)后自動(dòng)彈出對(duì)話(huà)框?qū)嵗a,然后在文章下面給大家介紹了angularjs頁(yè)面加載后自動(dòng)彈窗的實(shí)例代碼,感興趣的朋友參考下吧
    2017-08-08
  • AngularJS 異步解決實(shí)現(xiàn)方法

    AngularJS 異步解決實(shí)現(xiàn)方法

    這篇文章主要介紹了AngularJS 異步解決實(shí)現(xiàn)方法的相關(guān)資料,需要的朋友可以參考下
    2017-06-06
  • Angular.js去除頁(yè)面中顯示的空行方法示例

    Angular.js去除頁(yè)面中顯示的空行方法示例

    這篇文章主要介紹了Angular.js去除頁(yè)面中顯示的空行方法,文中給出了詳細(xì)的示例代碼供大家參考學(xué)習(xí),相信對(duì)大家具有一定的參考價(jià)值,需要的朋友們下面來(lái)一起看看吧。
    2017-03-03
  • 淺談Angular7 項(xiàng)目開(kāi)發(fā)總結(jié)

    淺談Angular7 項(xiàng)目開(kāi)發(fā)總結(jié)

    這篇文章主要介紹了淺談Angular7 項(xiàng)目開(kāi)發(fā)總結(jié),本文在此做一次遇到問(wèn)題的總結(jié),以便知識(shí)的掌握,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-12-12
  • 使用AngularJS實(shí)現(xiàn)可伸縮的頁(yè)面切換的方法

    使用AngularJS實(shí)現(xiàn)可伸縮的頁(yè)面切換的方法

    這篇文章主要介紹了使用AngularJS實(shí)現(xiàn)可伸縮的頁(yè)面切換的方法,AngularJS是一款熱門(mén)的JavaScript庫(kù),需要的朋友可以參考下
    2015-06-06
  • Angular5整合富文本編輯器TinyMCE的方法(漢化+上傳)

    Angular5整合富文本編輯器TinyMCE的方法(漢化+上傳)

    TinyMCE是一個(gè)輕量級(jí)的富文本編輯器,相對(duì)于CK編輯器更加精簡(jiǎn),但必須滿(mǎn)足絕大部分場(chǎng)景的需要。這篇文章主要介紹了Angular5整合富文本編輯器TinyMCE(漢化+上傳)的相關(guān)知識(shí),需要的朋友可以參考下
    2020-05-05
  • AngularJS上傳文件的示例代碼

    AngularJS上傳文件的示例代碼

    上傳文件在很多時(shí)候都能用到,這篇文章主要介紹了AngularJS上傳文件的示例代碼,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-11-11

最新評(píng)論

读书| 克东县| 巨鹿县| 濮阳县| 西华县| 宿迁市| 香港| 休宁县| 介休市| 阜康市| 株洲市| 塘沽区| 林周县| 松原市| 河源市| 张北县| 上林县| 衡水市| 怀集县| 彭水| 开封县| 古丈县| 蒙自县| 石景山区| 峨山| 乌兰浩特市| 宁明县| 郁南县| 蕲春县| 兖州市| 武宣县| 凤阳县| 潞城市| 楚雄市| 盐池县| 岳阳县| 建昌县| 洛浦县| 桓台县| 山东省| 青海省|