<! DOCTYPEHtml>
lang="EN">
<metacharset="UTF-8">
<title></title>
<scriptSrc="./js/angular-1.5.8.js"></script>
<bodyng-app="Mainapp"Ng-controller="Ngcontroller">
<inputType="Text"Ng-model="Time"style="Width50%;">
<script>
Angular.module ("Mainapp",[])
.Controller"Ngcontroller",function ($scope) {
$scope. Time=new Date (). toString ();
SetInterval (function () {
$scope.Time=New Date ().ToString ();
$scope.$apply ();//A manual call can force the data to be refreshed;
},100)
});
$apply ()What problems can be solved by the way?
//Problem Description: In fact$scopeThe data of the page is bound together, when the data of the page changes,$scopewill change as well;
//When the page appears asynchronous, the$scopeData processing in the,This can cause data to be out of sync.
//When it appearsajax request, It itself is asynchronous (the above is the description)
// (Note: When you add a $apply time This value on the function of the timing, is equal to the realization of the function of synchronization, if there is no such value, time $apply " is to solve the problem of asynchronous synchronization, use it to achieve the effect of synchronization)
</ Script>
</BODY>
</HTML>
$apply method is how to solve the problem of async