欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

AngularJS  $modal彈出框?qū)嵗a

 更新時(shí)間:2016年08月24日 08:59:10   作者:ngulc  
這篇文章主要介紹了AngularJS 彈出框 $modal,大家都知道open是$modal唯一方法,通過本文給大家列出了該方法的屬性。對(duì)angularjs彈出框知識(shí)感興趣的朋友一起看下吧

下面給大家說下$modal擁有一個(gè)方法:open,該方法的屬性介紹:

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

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

scope:一個(gè)作用域?yàn)槟B(tài)的內(nèi)容使用(事實(shí)上,$modal會(huì)創(chuàng)建一個(gè)當(dāng)前作用域的子作用域)默認(rèn)為$rootScope

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

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

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

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

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

open方法返回一個(gè)實(shí)例,該實(shí)例具有如下屬性:

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

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

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

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

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

<!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-0.7.0.min.js"></script>
<script src="lib/angular/i18n/angular-locale_zh-cn.js"></script>
</head>
<body>
<div ng-controller="ModalDemoCtrl">
<script type="text/ng-template" id="myModalContent.html" />
<div class="modal-header">
<h3>I'm a modal!</h3>
</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 = [ 'item1', 'item2', 'item3' ];
$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);// 點(diǎn)擊空白區(qū)域,總會(huì)輸出backdrop
// click,點(diǎn)擊取消,則會(huì)暑促cancel
$log.info('Modal dismissed at: ' + new Date());
});
};
};
var ModalInstanceCtrl = function($scope, $modalInstance, items) {
$scope.items = items;
$scope.selected = {
item : $scope.items[0]
};
$scope.ok = function() {
$modalInstance.close($scope.selected);
};
$scope.cancel = function() {
$modalInstance.dismiss('cancel');
};
};
</script>
</body>
</html>

以上所述是小編給大家介紹的AngularJS  $modal彈出框?qū)嵗a,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!

相關(guān)文章

  • Angularjs實(shí)現(xiàn)頁面模板清除的方法

    Angularjs實(shí)現(xiàn)頁面模板清除的方法

    這篇文章主要介紹了Angularjs實(shí)現(xiàn)頁面模板清除的方法,需要的朋友可以參考下
    2018-07-07
  • AngularJS封裝指令方法詳解

    AngularJS封裝指令方法詳解

    這篇文章主要介紹了AngularJS封裝指令方法,結(jié)合實(shí)例形式詳細(xì)分析了AngularJS的功能、jQuery類庫協(xié)作及組件封裝的具體操作技巧,需要的朋友可以參考下
    2016-12-12
  • AngularJs concepts詳解及示例代碼

    AngularJs concepts詳解及示例代碼

    本文主要介紹AngularJs concepts,這里整理了詳細(xì)資料及簡單示例代碼來講解相關(guān)知識(shí),有學(xué)習(xí)這部分知識(shí)的朋友可以參考下
    2016-09-09
  • AngularJS入門之動(dòng)畫

    AngularJS入門之動(dòng)畫

    AngularJS中ngAnimate模塊支持動(dòng)畫效果,但是ngAnimate模塊并未包含在AngularJS核心庫中,因此需要使用ngAnimate需要在定義Module時(shí)聲明對(duì)其的引用。下面通過本文我們來看看AngularJS動(dòng)畫的詳細(xì)介紹。
    2016-07-07
  • Angular實(shí)現(xiàn)的簡單查詢天氣預(yù)報(bào)功能示例

    Angular實(shí)現(xiàn)的簡單查詢天氣預(yù)報(bào)功能示例

    這篇文章主要介紹了Angular實(shí)現(xiàn)的簡單查詢天氣預(yù)報(bào)功能,涉及AngularJS針對(duì)第三方API接口交互的相關(guān)操作技巧,需要的朋友可以參考下
    2017-12-12
  • angular.js + require.js構(gòu)建模塊化單頁面應(yīng)用的方法步驟

    angular.js + require.js構(gòu)建模塊化單頁面應(yīng)用的方法步驟

    這篇文章主要給大家介紹了關(guān)于利用angular.js + require.js構(gòu)建模塊化單頁面應(yīng)用的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起看看吧。
    2017-07-07
  • Angular2學(xué)習(xí)教程之組件中的DOM操作詳解

    Angular2學(xué)習(xí)教程之組件中的DOM操作詳解

    這篇文章主要給大家介紹了Angular2學(xué)習(xí)教程之組件中DOM操作的相關(guān)資料,文中介紹的非常詳細(xì),對(duì)大家具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面跟著小編一起來看看吧。
    2017-05-05
  • angular仿支付寶密碼框輸入效果

    angular仿支付寶密碼框輸入效果

    本篇文章主要介紹了angular仿支付寶密碼框輸入效果,詳細(xì)的介紹了使用ng寫一個(gè)密碼框格子支付模塊,具有一定的參考價(jià)值,有興趣的可以了解一下。
    2017-03-03
  • 在AngularJS應(yīng)用中實(shí)現(xiàn)一些動(dòng)畫效果的代碼

    在AngularJS應(yīng)用中實(shí)現(xiàn)一些動(dòng)畫效果的代碼

    這篇文章主要介紹了在AngularJS應(yīng)用中實(shí)現(xiàn)一些動(dòng)畫效果的代碼,AngularJS是一款熱門的JavaScript庫,需要的朋友可以參考下
    2015-06-06
  • AngularJS 如何在控制臺(tái)進(jìn)行錯(cuò)誤調(diào)試

    AngularJS 如何在控制臺(tái)進(jìn)行錯(cuò)誤調(diào)試

    本文主要介紹AngularJS 如何在控制臺(tái)進(jìn)行錯(cuò)誤調(diào)試,還不錯(cuò),分享給大家,希望給大家做一個(gè)參考。
    2016-06-06

最新評(píng)論