天天看点

Angularjs总结(三)摸态框的使用

静态页面:

controllers中的方法:

1 $scope.TQZJDFG = function () {
 2     //可以将此参数传递到所弹出的摸态框的控制器中
 3     var data = {
 4         'name': 1,
 5         'age': 20
 6     }
 7     var modalInstance = $modal.open({
 8         templateUrl: 'partials/WindowView/_getInfo.html',
 9         controller: 'getInfo-controller',
10         backdrop: "true",
11         size: 900,
12         resolve: {
13             items: function () {
14                 return data;
15             }
16         }
17     });
18 
19     modalInstance.result.then(function (data) {
20 
21         //data为摸态框点击关闭时,传递回来的参数
22     }
23     )
24 }
           

模态框所需控制器,其中items即为TQZJDFG()方法中传递过来的data:

1 app.controller('getInfo-controller',['items','$modalInstance',function(items,$modalInstance){
2         //摸态框关闭
3         $modalInstance.dismiss('cancel');
4         //摸态框关闭传递相应参数回调用页面
5         $modalInstance.close(data);
6     }])
           

 创建可拖动指令见:http://www.cnblogs.com/bobo-show/p/5106204.html

更多专业前端知识,请上 【猿2048】www.mk2048.com