的index.html
var app = angular.module('myApp',[]);
app.run(function($rootScope){
$rootScope.isDisabled = true;
setTimeout(function(){
$rootScope.isDisabled = false;
},3000);
使用内置指令.js
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct Result{
int reversen;
unsigned short count;
};
struct Result *myCount(int, int);
int main()
{
struct Result *result;
myCount(122333, 2);
printf("\nReversed integer of 122333: %d", result->reversen);
printf("\nOccurrence of 2 in 122333: %hu", result->count);
return 0;
}
struct Result * myCount(int n, int d)
{
struct Result * result = (struct Result *) malloc (sizeof (struct Result));
if (result == NULL)
{
fprintf(stderr, "\nNo storage space available\n");
exit(0);
}
int rev_dig, last_dig, digit, count = 0;
while (n != 0)
{
last_dig = n % 10;
rev_dig = rev_dig * 10 + last_dig;
n = n / 10;
}
rev_dig = rev_dig * (-1);
result->reversen = rev_dig;
while (n >= 1)
{
digit = n % 10;
if (digit == d)
count++;
n = n / 10;
}
result->count = count;
}
在开始时页面加载按钮保持禁用状态,但在3秒后它未启用。那是为什么?
答案 0 :(得分:2)
当您使用setTimeout
时,模型更改在角度上下文之外完成,因此它不会触发摘要。
替换:
setTimeout(function(){
// ...
},3000);
与
$timeout(function(){
// ...
}, 3000);