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

AngularJs 彈出模態(tài)框(model)

 更新時間:2016年04月07日 13:42:46   投稿:mrr  
這篇文章主要介紹了AngularJs 彈出模態(tài)框(model)的相關(guān)資料,需要的朋友可以參考下

推薦閱讀:詳解AngularJS 模態(tài)對話框

$modal是一個可以迅速創(chuàng)建模態(tài)窗口的服務(wù),創(chuàng)建部分頁,控制器,并關(guān)聯(lián)他們。

$modal僅有一個方法open(options)

templateUrl:模態(tài)窗口的地址

template:用于顯示html標(biāo)簽

scope:一個作用域為模態(tài)的內(nèi)容使用(事實上,$modal會創(chuàng)建一個當(dāng)前作用域的子作用域)默認(rèn)為$rootScope

controller:為$modal指定的控制器,初始化$scope,該控制器可用$modalInstance注入

resolve:定義一個成員并將他傳遞給$modal指定的控制器,相當(dāng)于routes的一個reslove屬性,如果需要傳遞一個objec對象,需要使用angular.copy()

backdrop:控制背景,允許的值:true(默認(rèn)),false(無背景),“static” - 背景是存在的,但點擊模態(tài)窗口之外時,模態(tài)窗口不關(guān)閉

keyboard:當(dāng)按下Esc時,模態(tài)對話框是否關(guān)閉,默認(rèn)為ture

windowClass:指定一個class并被添加到模態(tài)窗口中

open方法返回一個模態(tài)實例,該實例有如下屬性

close(result):關(guān)閉模態(tài)窗口并傳遞一個結(jié)果

dismiss(reason):撤銷模態(tài)方法并傳遞一個原因

result:一個契約,當(dāng)模態(tài)窗口被關(guān)閉或撤銷時傳遞

opened:一個契約,當(dāng)模態(tài)窗口打開并且加載完內(nèi)容時傳遞的變量

另外,$modalInstance擴(kuò)展了兩個方法$close(result)、$dismiss(reason),這些方法很容易關(guān)閉窗口并且不需要額外的控制器

HTML

<!DOCTYPE html> 
<html ng-app="ModalDemo"> 
<head> 
<title></title> 
<link href="lib/bootstrap/css/bootstrap.min.css" rel="stylesheet"> 
<script src="lib/angular/angular.min.js"></script> 
<script src="lib/bootstrap-gh-pages/ui-bootstrap-tpls-...min.js"></script> 
<script src="lib/angular/in/angular-locale_zh-cn.js"></script> 
</head> 
<body> 
<div ng-controller="ModalDemoCtrl"> 
<script type="text/ng-template" id="myModalContent.html"> 
<div class="modal-header"> 
<h>I'm a modal!</h> 
</div> 
<div class="modal-body"> 
<ul> 
<li ng-repeat="item in items"> 
<a ng-click="selected.item = item">{{ item }}</a> 
</li> 
</ul> 
Selected: <b>{{ selected.item }}</b> 
</div> 
<div class="modal-footer"> 
<button class="btn btn-primary" ng-click="ok()">OK</button> 
<button class="btn btn-warning" ng-click="cancel()">Cancel</button> 
</div> 
</script> 
<button class="btn" ng-click="open()">Open me!</button> 
</div> 
<script> 
var ModalDemo = angular.module('ModalDemo', ['ui.bootstrap']); 
var ModalDemoCtrl = function ($scope, $modal, $log) { 
$scope.items = ['item', 'item', 'item']; 
$scope.open = function () { 
var modalInstance = $modal.open({ 
templateUrl: 'myModalContent.html', 
controller: ModalInstanceCtrl, 
resolve: { 
items: function () { 
return $scope.items; 
} 
} 
}); 
modalInstance.opened.then(function(){//模態(tài)窗口打開之后執(zhí)行的函數(shù) 
console.log('modal is opened'); 
}); 
modalInstance.result.then(function (result) { 
console.log(result); 
}, function (reason) { 
console.log(reason);//點擊空白區(qū)域,總會輸出backdrop click,點擊取消,則會暑促cancel 
$log.info('Modal dismissed at: ' + new Date()); 
}); 
}; 
}; 
var ModalInstanceCtrl = function ($scope, $modalInstance, items) { 
$scope.items = items; 
$scope.selected = { 
item: $scope.items[] 
}; 
$scope.ok = function () { 
$modalInstance.close($scope.selected); 
}; 
$scope.cancel = function () { 
$modalInstance.dismiss('cancel'); 
}; 
}; 
</script> 
</body> 
</html> 

以上所述是小編給大家介紹的AngularJs 彈出模態(tài)框(model)的相關(guān)內(nèi)容,希望對大家有所幫助!

相關(guān)文章

  • angularJS 指令封裝回到頂部示例詳解

    angularJS 指令封裝回到頂部示例詳解

    本篇文章主要介紹了angularJS 指令封裝回到頂部示例詳解,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-01-01
  • AngularJS中控制器函數(shù)的定義與使用方法示例

    AngularJS中控制器函數(shù)的定義與使用方法示例

    這篇文章主要介紹了AngularJS中控制器函數(shù)的定義與使用方法,結(jié)合具體實例形式分析了AngularJS控制器函數(shù)的定義、綁定及相關(guān)使用技巧,需要的朋友可以參考下
    2017-10-10
  • angular6的table組件開發(fā)的實現(xiàn)示例

    angular6的table組件開發(fā)的實現(xiàn)示例

    這篇文章主要介紹了angular6的table組件開發(fā)的實現(xiàn)示例,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-12-12
  • 使用Angular.js開發(fā)的注意事項

    使用Angular.js開發(fā)的注意事項

    這篇文章主要記錄了一些在學(xué)習(xí)和使用angular.js踩到的坑和需要注意的點,方便以后自己查閱,也給同樣遇到這些問題的朋友們一些幫助,有需要的朋友們下面來一起看看吧。
    2016-10-10
  • 詳解基于Bootstrap+angular的一個豆瓣電影app

    詳解基于Bootstrap+angular的一個豆瓣電影app

    本篇文章主要介紹了基于Bootstrap+angular的一個豆瓣電影app ,非常具有實用價值,需要的朋友可以參考下
    2017-06-06
  • Angular實現(xiàn)的簡單定時器功能示例

    Angular實現(xiàn)的簡單定時器功能示例

    這篇文章主要介紹了Angular實現(xiàn)的簡單定時器功能,結(jié)合實例形式分析了AngularJS定時器功能的簡單實現(xiàn)與使用技巧,需要的朋友可以參考下
    2017-12-12
  • Angular應(yīng)用里環(huán)境變量SERVER_REQUEST_ORIGIN含義解析

    Angular應(yīng)用里環(huán)境變量SERVER_REQUEST_ORIGIN含義解析

    這篇文章主要為大家介紹了Angular應(yīng)用里環(huán)境變量SERVER_REQUEST_ORIGIN的含義解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-10-10
  • 淺談Angular 的變化檢測的方法

    淺談Angular 的變化檢測的方法

    這篇文章主要介紹了淺談Angular 的變化檢測的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-03-03
  • Angular刷新當(dāng)前頁面的實現(xiàn)方法

    Angular刷新當(dāng)前頁面的實現(xiàn)方法

    這篇文章主要介紹了Angular刷新當(dāng)前頁面的實現(xiàn)方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-11-11
  • RequireJs的使用詳解

    RequireJs的使用詳解

    本文主要介紹了RequireJs的使用。具有很好的參考價值,下面跟著小編一起來看下吧
    2017-02-02

最新評論

佛学| 台中市| 永和县| 杭锦旗| 奎屯市| 河源市| 轮台县| 乐平市| 元氏县| 元谋县| 黑山县| 宜丰县| 呼伦贝尔市| 环江| 明溪县| 隆德县| 泗阳县| 道孚县| 资阳市| 高要市| 城固县| 融水| 海兴县| 闽侯县| 蓬安县| 滨州市| 鲁山县| 抚顺市| 顺义区| 重庆市| 巫山县| 饶河县| 美姑县| 罗源县| 神木县| 永城市| 汽车| 辉县市| 张掖市| 凤庆县| 定南县|