這篇文章給大家介紹如何正確的使用angularjs模態框,內容非常詳細,感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
1.觸發模態框的點擊事件
<div>
<button type="button" class="btn btn-primary" ng-click="openAddModal()" data-toggle="modal"
data-target="#documentOprModal" >
<i class="glyphicon glyphicon-plus"></i>{{ 'i18n.add' | translate }}
</button>
</div>2.模態框頁面
<div class="modal fade" id="documentOprModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
data-backdrop="static" data-keyboard="false">
<div class="modal-dialog modal-lg" role="document" >
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h5 class="modal-title" id="myModalLabel"> 文檔入庫</h5>
</div>
<div class="modal-body">
<!--開發-->
<form name="docForm" id="docForm" novalidate>
<!-- 分類 -->
<div class="form-group">
<label class="col-lg-12 col-md-12 col-xs-12" >分類:</label>
<div class="input-group col-lg-12 col-md-12 col-xs-12">
<div class="input-group">
<input type="text" ng-model="document.classification_name" class="form-control"
placeholder="選擇分類">
<div class="input-group-btn">
<button type="button" class="btn btn-default"
ng-click="toggleDetail()"> <span class="caret"></span></button>
</div>
</div>
<div ng-show="isShowDetail" >
<div class="panel panel-default">
<div class="panel-body list-group list-group-contacts">
<div>
<ul id="classify-tree" class="ztree"></ul>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 星級 -->
<div class="form-group">
<label class="col-lg-12 col-md-12 col-xs-12" >星級:</label>
<div class="input-group col-lg-12 col-md-12 col-xs-12">
<ui-select ng-model="document.starGrade" theme="selectize">
<ui-select-match placeholder="請選擇星級">
<span ng-bind="$select.selected.name"></span>
</ui-select-match>
<ui-select-choices
repeat="item.id as item in (starGrades | filter: $select.search) track by $index ">
<div ng-bind-html="item.name | highlight: $select.search"></div>
</ui-select-choices>
</ui-select>
</div>
</div>
<!-- 井號 -->
<div class="form-group">
<label for="jhText">井號:</label>
<input type="text" class="form-control" id="jhText" ng-model="document.jh">
</div>
<!-- 作者 -->
<div class="form-group">
<label for="authorText">作者:</label>
<input type="text" class="form-control" id="authorText" ng-model="document.author">
</div>
<!-- 單位 -->
<div class="form-group">
<label for="unitText">單位:</label>
<input type="text" class="form-control" id="unitText" ng-model="document.unit">
</div>
<!-- 日期 -->
<div class="form-group">
<label for="writeDate">寫作日期:</label>
<input type="date" class="form-control" id="writeDate" ng-model="document.writeDate">
</div>
<!-- 簡介 -->
<div class="form-group">
<label for="introductionTextArea">簡介:</label>
<textarea class="form-control" id="introductionTextArea" ng-model="document.introduction"
rows="5" cols="60"></textarea>
</div>
<!-- 可能的查詢關鍵字 -->
<div class="form-group">
<label for="keyPackageTextArea">可能的查詢關鍵字:</label>
<textarea class="form-control" id="keyPackageTextArea" ng-model="document.keyPackage" rows="5"
cols="60"></textarea>
</div>
<!-- 文件 -->
<div class="form-group">
<div id="inputContent">
<input id="importFile" type="file" name="file" class="file-loading">
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" ng-click="submitFileInfo()"><i class="fa fa-check"></i>{{ 'i18n.save'
| translate }}
</button>
<button type="button" class="btn btn-default" data-dismiss="modal" ><i
class="fa fa-ban"></i>{{
'i18n.cancel' | translate }}
</button>
</div>
</div>
</div>
</div>3.編寫對應的js
/**
* 點擊 添加事件打開模態框
*/
function openAddModal() {
$('#documentOprModal').modal({
show: true,
keyboard: false,
backdrop: 'static'
});
}關于如何正確的使用angularjs模態框就分享到這里了,希望以上內容可以對大家有一定的幫助,可以學到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。