AngularJS创建对话框,利用$window实现对话框
2、实现源码
<!DOCTYPE html>
<html ng-app="winApp">
<head>
<meta charset="UTF-8">
<title>AngularJS之对话框</title>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script>
var app = angular.module("winApp",[]);
app.factory("$show",function($window){
return{
show:function(content){
$window.alert(content);
}
};
});
var control = function($scope,$show){
$scope.tanClick = function(message){
$show.show(message);
}
}
app.controller("winCon",control);
</script>
</head>
<body>
<p ng-controller="winCon">
<button ng-click="tanClick('对话框!')">对话框</button>
</p>
</body>
</html>
3、实现结果
Copyright © 2019- 07swz.com 版权所有
违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务