首页 技术 正文
技术 2022年11月17日
0 收藏 394 点赞 3,263 浏览 1155 个字

$mdDialog以一个点击button按钮出现弹框为例:

$scope.btn=function($event,row){

  var dScope = $scope.$new(true);

  dScope.row = row;//从新new一个$scope,把当前值带到弹框中,页面可直接绑定收据,js用前加$scope

  $mdDialog.show({

    scope:dScope,

    parent:angular.element(document.body),

    targetEvent: $event,

    size:’sm’,

    clickOutsideToClose:false, //点击弹框外是否关闭弹框

    templateUrl:’弹框的页面所在路径’,

    locals:{store:$scope.store}, //这个在弹框的controller里边运用不需要再加$scope,所以不能双向绑定到页面,如果要绑定到页面需要从新赋值

    controller:[‘$scope’,function($scope){

      //………弹框里边的一些逻辑………….

      比如我里边有个逻辑执行完成后弹框关闭,想要把里边的一个$scope.currentValue值返回到主页面中

      那么执行弹框关闭的方法是$mdDialog.cancel($scope.currentValue),只要把值传过来就行了。在下边then的回调函数function会接收到这个值

    }]

  }).then(function(ret){

    // 这里边是接收$mdDialog.hide()传过来的值

  },function(ret){

    // 这里边是接收$mdDialog.cancel()传过来的值

    比如我的主页面绑定值是$scope.currentVal =  ret;

  });

};

$uibModal以一个点击button按钮出现弹框为例:

  $scope.btn=function(oper){

    var dScope = $scope.$new(true);

    dScope.oper = oper;//这个值传到弹框页面可直接绑定数据,js里用前加$scope

    var modalInstance = $uibModal.open({

      scope:dScope,

      animation: true,

      templateUrl:’弹框页面所在路径’,

      controller: ‘btnCtrl’,   //弹框的controller

      size:’lg’  //控制弹框大小 /sm

    });

  }

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,078
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,553
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,402
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,177
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,814
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,898