0
내보기에서 지연된 작업을 만들려고합니다.
버튼을 클릭하면 해당 메시지가 나타나지만 2000ms에 메시지가 사라지게하고 싶습니다.
$timeout
을 추천 한 적이 있는데 이러한 경우 솔루션을 겉으로보기에는했지만 문자 텍스트는 $timeout
기능으로 변경되지 않은 경우가 있습니다.
내 $timeout
이이 경우 작동하지 않는 이유는 무엇입니까?
문제에 대한 모든 안내를 감사드립니다. 아래 코드를 찾으십시오.
//
var app = angular.module('myApp', []);
// mainController.js
app.controller("mainController", ["$scope", function($scope, $timeout) {
$scope.fireTrigger = function(str) {
$scope.triggeredValue = (str) + " fired";
$timeout(function() {
$scope.triggeredValue = "";
}, 2000);
}
}]);
// index.html을
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title>myApp</title>
<link rel="stylesheet"
href="entertainment.css">
</head>
<body ng-controller="mainController">
<h3 ng-bind="triggeredValue"></h3>
// ...
감사합니다. 나도 onclick 함수 내에서 함수 자체를 호출하는 것을 잊었던 것으로 나타났습니다. –