angularjs模态框的使用代码实例

这篇文章主要介绍了angularjs模态框的使用代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下

编写html页面

1.触发模态框的点击事件

<div> <button type="button" ng-click="openAddModal()" data-toggle="modal" data-target="#documentOprModal"> <i></i>{{ 'i18n.add' | translate }} </button> </div>

2.模态框页面

<div tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static" data-keyboard="false"> <div role="document"> <div> <div> <button type="button" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> <h4> 文档入库</h4> </div> <div> <!--开发--> <form novalidate> <!-- 分类 --> <div> <label>分类:</label> <div> <div> <input type="text" ng-model="document.classification_name" placeholder="选择分类"> <div> <button type="button" ng-click="toggleDetail()"> <span></span></button> </div> </div> <div ng-show="isShowDetail"> <div> <div> <div> <ul></ul> </div> </div> </div> </div> </div> </div> <!-- 星级 --> <div> <label>星级:</label> <div> <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> <label for="jhText">井号:</label> <input type="text" ng-model="document.jh"> </div> <!-- 作者 --> <div> <label for="authorText">作者:</label> <input type="text" ng-model="document.author"> </div> <!-- 单位 --> <div> <label for="unitText">单位:</label> <input type="text" ng-model="document.unit"> </div> <!-- 日期 --> <div> <label for="writeDate">写作日期:</label> <input type="date" ng-model="document.writeDate"> </div> <!-- 简介 --> <div> <label for="introductionTextArea">简介:</label> <textarea ng-model="document.introduction" rows="5" cols="60"></textarea> </div> <!-- 可能的查询关键字 --> <div> <label for="keyPackageTextArea">可能的查询关键字:</label> <textarea ng-model="document.keyPackage" rows="5" cols="60"></textarea> </div> <!-- 文件 --> <div> <div> <input type="file"> </div> </div> </form> </div> <div> <button type="button" ng-click="submitFileInfo()"><i></i>{{ 'i18n.save' | translate }} </button> <button type="button" data-dismiss="modal"><i></i>{{ 'i18n.cancel' | translate }} </button> </div> </div> </div> </div>

3.编写对应的js

/** * 点击 添加事件打开模态框 */ function openAddModal() { $('#documentOprModal').modal({ show: true, keyboard: false, backdrop: 'static' }); }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/c1566d80fd9288c2bd82c6599a898f3b.html