• angular $modal模态框


    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="UTF-8">
    		<title></title>
    		<link rel="stylesheet" type="text/css" href="libs/bootstrap/dist/css/bootstrap.min.css"/>
    		<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.js"></script>
        <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-animate.js"></script>
        <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-sanitize.js"></script>
        <script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.5.0.js"></script>
    	</head>
    	<body ng-app='myapp' >
    		<h1 ng-controller='mycontroller' ng-click='kitme("lg")'>点我</h1>
    		 <script type="text/ng-template" id="test.html">      //angular的模态框是可以载入一个html页面的,这里通过ng-template来创建一个html模块,也可以创建一个html文件。
            <div class="modal-header">
                <h3 class="modal-title" id="modal-title">hello</h3>
            </div>
            <div class="modal-body" id="modal-body">
            	<h1>就翻身解放了就</h1>
            </div>
            <div class="modal-footer">
                <button class="btn btn-primary" type="button" ng-click="ok()">OK</button>
                <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button>
            </div>
        </script>
    		<script type="text/javascript">
    			angular.module('myapp',['ngAnimate', 'ngSanitize', 'ui.bootstrap']).controller('mycontroller',function ($scope,$uibModal){
    				$scope.item='item465554645';
    				$scope.kitme=function(size){
    					var modalInstance=$uibModal.open({
    						 animation:true,   
          					 ariaLabelledBy: 'modal-title',
          					ariaDescribedBy: 'modal-body',
          					templateUrl: 'test.html',  //载入的html文件
          					controller: 'ModalInstanceCtrl',  //为载入的文件定义一个控制器
          					size: size,  // size : lg sm 两值
          					resolve: {   //resolve是成功创建模态框时,将有效数据传给模态框的控制器,模态框的控制通过注入的形式获取,这里传送了一个item的值;
            					item: function () {
              						return $scope.item;
            					}
         					 }
    					});
    					modalInstance.result.then(function (selected) {  //配合模态框模块执行完毕,成功关闭后执行的回调函数。selected是模态框传过来的值。
          					alert(selected);
        					}, function () {
    						alert('error');
        				},function (){
                            //取消关闭后执行。
                        }); }; }); angular.module('myapp').controller('ModalInstanceCtrl',function($uibModalInstance,$scope,item){ //此控制器只有在模态框成功打开时才会执行。 $scope.ok = function () { $uibModalInstance.close('wang'); //close方法会将参数值回调返回。 }; $scope.cancel = function () { $uibModalInstance.dismiss('cancel'); //关闭模态框,也会执行回调。 }; }); </script> </body> </html>

      

  • 相关阅读:
    2015.2.27 UltraEdit中显示XML结构
    2015.1.31 DataGridView自动滚动到某行
    2015.1.15 利用函数实现将一行记录拆分成多行记录 (多年想要的效果)
    2015.1.15 利用Oracle函数返回表结果 重大技术进步!
    2015.1.15 利用Oracle函数插入表结构 Bulk collect into 不用循环,简洁高效
    2015.1.8 Left join 左连接
    2015.1.10 解决DataGridView SelectionChanged事件自动触发问题
    delphi 遍历窗口
    delphi 访问 protected 属性 哈哈
    clientdataset 读取excel 如果excel 文件不存在的时候 相应的gird 会不显示数据, 鼠标掠过 gird 格子 才会显示数据。 这是一个bug 哈哈
  • 原文地址:https://www.cnblogs.com/changyaoself/p/7382674.html
Copyright © 2020-2023  润新知