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

ionic js 模型 $ionicModal 可以遮住用戶主界面的內(nèi)容框

 更新時間:2016年06月06日 15:13:00   作者:yongbin668  
這篇文章主要介紹了ionic js 模型 $ionicModal 可以遮住用戶主界面的內(nèi)容框的相關(guān)資料,需要的朋友可以參考下

 ionic 模型

$ionicModal

$ionicModal 可以遮住用戶主界面的內(nèi)容框。

你可以在你的 index 文件或者是其他文件內(nèi)嵌入以下代碼(里面的代碼可以根據(jù)你自己的業(yè)務(wù)場景相應(yīng)的改變)。

<script id="my-modal.html" type="text/ng-template">
<ion-modal-view>
<ion-header-bar>
<h1 class="title">My Modal title</h1>
</ion-header-bar>
<ion-content>
Hello!
</ion-content>
</ion-modal-view>
</script>

然后你就可以在你的 Controller 里面的注入 $ionicModal 。然后調(diào)用你剛剛寫入的模板,進(jìn)行初始化操作。就像下面的代碼:

angular.module('testApp', ['ionic'])
.controller('MyController', function($scope, $ionicModal) {
$ionicModal.fromTemplateUrl('my-modal.html', {
scope: $scope,
animation: 'slide-in-up'
}).then(function(modal) {
$scope.modal = modal;
});
$scope.openModal = function() {
$scope.modal.show();
};
$scope.closeModal = function() {
$scope.modal.hide();
};
//Cleanup the modal when we're done with it!
$scope.$on('$destroy', function() {
$scope.modal.remove();
});
// Execute action on hide modal
$scope.$on('modal.hidden', function() {
// Execute action
});
// Execute action on remove modal
$scope.$on('modal.removed', function() {
// Execute action
});
});

方法

fromTemplate(templateString, options)

參數(shù) 類型 詳情
templateString 字符串

模板的字符串作為模型的內(nèi)容。

options 對象
options 會傳遞到 ionicModal#initialize方法中。

返回: 對象, 一個ionicModal控制器的實(shí)例。

fromTemplateUrl(templateUrl, options)

參數(shù) 類型 詳情
templateUrl 字符串
載入模板的url。
options 對象
通過ionicModal#initialize方法傳遞對象。

返回: promise對象。Promises對象是CommonJS工作組提出的一種規(guī)范,目的是為異步編程提供統(tǒng)一接口。

ionicModal

由$ionicModal服務(wù)實(shí)例化。

提示:當(dāng)你完成每個模塊清除時,確保調(diào)用remove()方法,以避免內(nèi)存泄漏。

注意:一個模塊從它的初始范圍廣播出 'modal.shown' 和 'modal.hidden' ,把自身作為一個參數(shù)來傳遞。

方法

initialize(可選)

創(chuàng)建一個新的模型控制器示例。

參數(shù) 類型 詳情
options 對象
一個選項(xiàng)對象具有一下屬性:
  • {object=} 范圍 子類的范圍。默認(rèn):創(chuàng)建一個$rootScope子類。
  • {string=} 動畫 帶有顯示或隱藏的動畫。默認(rèn):'slide-in-up'
  • {boolean=} 第一個輸入框獲取焦點(diǎn) 當(dāng)顯示時,模型的第一個輸入元素是否自動獲取焦點(diǎn)。默認(rèn):false。
  • {boolean=}backdropClickToClose` 點(diǎn)擊背景時是否關(guān)閉模型。默認(rèn):true。

show()

顯示模型實(shí)例

返回值: promise promise對象,在模型完成動畫后得到解析

hide()

隱藏模型。

返回值: promise promise對象,在模型完成動畫后得到解析

remove()

從 DOM 中移除模型實(shí)例并清理。

返回值: promise promise對象,在模型完成動畫后得到解析

isShown()

返回:布爾值,用于判斷模型是否顯示。

實(shí)例

HTML 代碼

<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 
<title>菜鳥教程(runoob.com)</title>
<link  rel="stylesheet">
<script src="http://www.runoob.com/static/ionic/js/ionic.bundle.min.js"></script>
</head>
<body ng-controller="AppCtrl">
<ion-header-bar class="bar-positive">
<h1 class="title">Contacts</h1>
<div class="buttons">
<button class="button button-icon ion-compose" ng-click="modal.show()">
</button>
</div>
</ion-header-bar>
<ion-content>
<ion-list>
<ion-item ng-repeat="contact in contacts">
{{contact.name}}
</ion-item>
</ion-list>
</ion-content>
<script id="templates/modal.html" type="text/ng-template">
<ion-modal-view>
<ion-header-bar class="bar bar-header bar-positive">
<h1 class="title">New Contact</h1>
<button class="button button-clear button-primary" ng-click="modal.hide()">Cancel</button>
</ion-header-bar>
<ion-content class="padding">
<div class="list">
<label class="item item-input">
<span class="input-label">First Name</span>
<input ng-model="newUser.firstName" type="text">
</label>
<label class="item item-input">
<span class="input-label">Last Name</span>
<input ng-model="newUser.lastName" type="text">
</label>
<label class="item item-input">
<span class="input-label">Email</span>
<input ng-model="newUser.email" type="text">
</label>
<button class="button button-full button-positive" ng-click="createContact(newUser)">Create</button>
</div>
</ion-content>
</ion-modal-view>
</script>
</body>
</html>

CSS 代碼

body {
cursor: url('http://www.runoob.com/try/demo_source/finger.png'), auto;
}

JavaScript 代碼

angular.module('ionicApp', ['ionic'])
.controller('AppCtrl', function($scope, $ionicModal) {
$scope.contacts = [
{ name: 'Gordon Freeman' },
{ name: 'Barney Calhoun' },
{ name: 'Lamarr the Headcrab' },
];
$ionicModal.fromTemplateUrl('templates/modal.html', {
scope: $scope
}).then(function(modal) {
$scope.modal = modal;
});
$scope.createContact = function(u) { 
$scope.contacts.push({ name: u.firstName + ' ' + u.lastName });
$scope.modal.hide();
};
});

完整源碼:

<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>
<link  rel="stylesheet">
<script src="http://cdn.bootcss.com/ionic/1.0.1/js/ionic.bundle.min.js"></script>
<style>
body {
cursor: url('http://ionicframework.com/img/finger.png'), auto;
}
</style>
<script>
angular.module('ionicApp', ['ionic']
.controller('AppCtrl', function($scope, $ionicModal) {
$scope.contacts = [
{ name: 'Gordon Freeman' },
{ name: 'Barney Calhoun' },
{ name: 'Lamarr the Headcrab' },
];
$ionicModal.fromTemplateUrl('templates/modal.html', {
scope: $scope
}).then(function(modal) {
$scope.modal = modal;
});
$scope.createContact = function(u) { 
$scope.contacts.push({ name: u.firstName + ' ' + u.lastName });
$scope.modal.hide();
};
});
</script>
</head>
<body ng-controller="AppCtrl">
<ion-header-bar class="bar-positive">
<h1 class="title">Contacts</h1>
<div class="buttons">
<button class="button button-icon ion-compose" ng-click="modal.show()">
</button>
</div>
</ion-header-bar>
<ion-content>
<ion-list>
<ion-item ng-repeat="contact in contacts">
{{contact.name}}
</ion-item>
</ion-list>
</ion-content>
<script id="templates/modal.html" type="text/ng-template">
<ion-modal-view>
<ion-header-bar class="bar bar-header bar-positive">
<h1 class="title">New Contact</h1>
<button class="button button-clear button-primary" ng-click="modal.hide()">Cancel</button>
</ion-header-bar>
<ion-content class="padding">
<div class="list">
<label class="item item-input">
<span class="input-label">First Name</span>
<input ng-model="newUser.firstName" type="text">
</label>
<label class="item item-input">
<span class="input-label">Last Name</span>
<input ng-model="newUser.lastName" type="text">
</label>
<label class="item item-input">
<span class="input-label">Email</span>
<input ng-model="newUser.email" type="text">
</label>
<button class="button button-full button-positive" ng-click="createContact(newUser)">Create</button>
</div>
</ion-content>
</ion-modal-view>
</script>
</body>
</html>

相關(guān)文章

  • JavaScript請求后臺數(shù)據(jù)的常用方法匯總

    JavaScript請求后臺數(shù)據(jù)的常用方法匯總

    這篇文章主要介紹了JavaScript請求后臺數(shù)據(jù)的幾種常用方式,本文通過示例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-06-06
  • javascript 將共享屬性遷移到原型中去的實(shí)現(xiàn)方法

    javascript 將共享屬性遷移到原型中去的實(shí)現(xiàn)方法

    下面小編就為大家?guī)硪黄猨avascript 將共享屬性遷移到原型中去的實(shí)現(xiàn)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2016-08-08
  • 詳解JSONObject和JSONArray區(qū)別及基本用法

    詳解JSONObject和JSONArray區(qū)別及基本用法

    這篇文章主要介紹了詳解JSONObject和JSONArray區(qū)別及基本用法,需要的朋友可以參考下
    2017-10-10
  • JavaScript onclick與addEventListener使用的區(qū)別介紹

    JavaScript onclick與addEventListener使用的區(qū)別介紹

    addEventListener()方法用于向指定元素添加事件句柄,使用 removeEventListener()方法來移除,onclick和addEventListener事件區(qū)別是:onclick事件會被覆蓋,而addEventListener可以先后運(yùn)行不會被覆蓋,addEventListener可以監(jiān)聽多個事件
    2022-09-09
  • 淺談JavaScript閉包

    淺談JavaScript閉包

    這篇文章主要介紹了JavaScript閉包,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • javascript實(shí)現(xiàn)多欄閉合展開式廣告位菜單效果實(shí)例

    javascript實(shí)現(xiàn)多欄閉合展開式廣告位菜單效果實(shí)例

    這篇文章主要介紹了javascript實(shí)現(xiàn)多欄閉合展開式廣告位菜單效果,可實(shí)現(xiàn)類似手風(fēng)琴切換展示效果的功能,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-08-08
  • JavaScript實(shí)現(xiàn)給數(shù)字添加千位分隔符

    JavaScript實(shí)現(xiàn)給數(shù)字添加千位分隔符

    這篇文章主要為大家詳細(xì)介紹了JavaScript如何實(shí)現(xiàn)給數(shù)字添加千位分隔符,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2023-11-11
  • JS正則表達(dá)式完美實(shí)現(xiàn)身份證校驗(yàn)功能

    JS正則表達(dá)式完美實(shí)現(xiàn)身份證校驗(yàn)功能

    這篇文章主要介紹了JS正則表達(dá)式完美實(shí)現(xiàn)身份證校驗(yàn)功能,需要的朋友可以參考下
    2017-10-10
  • ES6中module模塊化開發(fā)實(shí)例淺析

    ES6中module模塊化開發(fā)實(shí)例淺析

    這篇文章主要介紹了ES6中module模塊化開發(fā),結(jié)合實(shí)例形式分析了ES6中模塊化開發(fā)的相關(guān)功能、使用方法與相關(guān)注意事項(xiàng),需要的朋友可以參考下
    2017-04-04
  • JavaScript ParseFloat()方法

    JavaScript ParseFloat()方法

    parseFloat()方法可以解析一個字符串,并返回一個浮點(diǎn)數(shù)。本文給大家分享javascript parsefloat()方法的相關(guān)知識,對javascript parsefloat相關(guān)知識感興趣的朋友一起學(xué)習(xí)吧
    2015-12-12

最新評論