angularjs--服务

angularjs--服务

 1 <!DOCTYPE html>
 2 <html lang="en">
 3 <head>
 4     <meta charset="UTF-8">
 5     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
 6     <title>index</title>
 7     <link href="{$Think.const.CSSURL}bootstrap.min.css" rel="stylesheet" type="text/css"/>
 8     <script src="{$Think.const.JS}jquery.min.js" type="text/javascript"></script>
 9     <script src="{$Think.const.JS}bootstrap.min.js" type="text/javascript"></script>
10     <script src="{$Think.const.JS}angular.min.js" type="text/javascript"></script>
11     <link href="{$Think.const.CSSURL}home/index.css" rel="stylesheet" type="text/css"/>
12 </head>
13 <body ng-app="myapp" ng-controller="myctrl">
14 <div class="container">
15     <h1 class="page-header">前端技术</h1>
16     <div class="well">url: <span class="label label-success">{{url}}</span></div>
17     <div class="well">num: <span class="label label-success">{{num}}</span></div>
18     <img src="{$Think.const.HOMEIMG}/01.png" />
19 </div>
20 </body>
21 <script>
22     app = angular.module("myapp",[]);
23     app.controller("myctrl",function($scope,$location,$timeout,$interval){
24         //超时器服务
25         $timeout(function () {
26             //url地址服务
27             $scope.url = $location.absUrl();
28         },2000);
29 
30         $scope.num = 0;
31         s=1;
32         v=1;
33         //定时器服务
34         $interval(function(){
35             s+=v;
36             $scope.num = s;
37         },1000);
38     });
39 </script>
40 </html>

 

posted @ 2017-02-03 02:06  yuge790615  阅读(133)  评论(0编辑  收藏  举报