html
JS 需要注入$interval
var app = angular.module("passwordApp", []); app.controller(‘passwordController‘, [‘$scope‘, ‘$interval‘, function ($scope, $interval) { $scope.time=0; $scope.send=false; $scope.sendMessage=function(){ $scope.send=true; $scope.time=10; $scope.showTime(); } $scope.showTime=function(){ var time = $interval(function () { $scope.time--; if ($scope.time == 0) { $interval.cancel(time); $scope.send=false; } },1000); } }]);
实现效果
点击前效果
点击后效果