摘要:  

小宝典致力于为广大程序猿(媛)提供高品质的代码服务,请大家多多光顾小站,小宝典在此谢过。

Angular JS:第一个小案例

 <!DOCTYPE html>   <html ng-app="app">          <head>           <meta charset="utf-8" />           <title>Angular JS Hello World!</title>           <script src="https://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>       </head>          <body>           <p ng-controller="mainController">               <h1>Hello {{ message }}</h1>           </p>           <p ng-controller="myController">               <h1>当前时间 : <font color="orangered">{{ clock }}</font></h1>           </p>       </body>       <script>           var myApp = angular.module('app', []);           myApp.controller('mainController', function($scope) {               $scope.message = "Plunker";           });           myApp.controller('myController', function($scope, $timeout) {               var updateClock = function() {                   var da = new Date();                   var year = da.getFullYear()+'年';                   var month = da.getMonth()+1+'月';                   var dates = da.getDate()+'日';                   var now = year+month+dates;                   var s = da.getHours()+'时';                   var f = da.getMinutes()+'分';                   var m = da.getSeconds();                   now = now +s+f+m;                   $scope.clock = now;                   $timeout(function() {                       updateClock();                   }, 1000);               };               updateClock();           });       </script>      </html>  

 

Angular JS:第一个小案例

 <!DOCTYPE html>   <html ng-app="app">          <head>           <meta charset="utf-8" />           <title>Angular JS Hello World!</title>           <script src="https://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>       </head>          <body>           <p ng-controller="mainController">               <h1>Hello {{ message }}</h1>           </p>           <p ng-controller="myController">               <h1>当前时间 : <font color="orangered">{{ clock }}</font></h1>           </p>       </body>       <script>           var myApp = angular.module('app', []);           myApp.controller('mainController', function($scope) {               $scope.message = "Plunker";           });           myApp.controller('myController', function($scope, $timeout) {               var updateClock = function() {                   var da = new Date();                   var year = da.getFullYear()+'年';                   var month = da.getMonth()+1+'月';                   var dates = da.getDate()+'日';                   var now = year+month+dates;                   var s = da.getHours()+'时';                   var f = da.getMinutes()+'分';                   var m = da.getSeconds();                   now = now +s+f+m;                   $scope.clock = now;                   $timeout(function() {                       updateClock();                   }, 1000);               };               updateClock();           });       </script>      </html>  

 

觉得可用,就经常来吧!Javascript技巧 脚本宝典 欢迎评论哦! js技巧,巧夺天工,精雕玉琢。小宝典献丑了!

本文固定链接: http://www.js-code.com/js/js_1628.html