AngularJs中的$window服务,和JS中的window一样,测试代码如下:
04 | <meta charset= "UTF-8" > |
05 | <title>$window服务的实例</title> |
07 | <body ng-app= "app" ng-controller= "ctr" > |
08 | <button ng-click= "func();" >按钮</button> |
12 | <script type = "text/javascript" src= "http://www.zymseo.com/js/demo.js" ></script> |
13 | <script type = "text/javascript" src= "http://www.zymseo.com/js/angular.min.js" ></script> |
14 | <script type = "text/javascript" > |
15 | var m = angular.module( 'app' , []); |
16 | m.controller( 'ctr' , [ '$scope' , '$window' , function ($scope, $window){ |
17 | $scope.func = function (){ |
18 | if ($window.confirm( '确认操作?' )){ |
19 | $scope.message = '您点击了确认' ; |
21 | $scope.message = '您点击了取消' ; |
|