0
我試圖通過單擊按鈕來刷新驗證碼。但它不會進入功能本身。我錯過了什麼?這裏是我的controller.js代碼:ng-click不會輸入函數本身
$scope.goCaptcha = function()
{
console.log('entered');
var alpha = new Array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4','5','6','7','8','9','0');
var i;
for (i = 0; i < 6; i++) {
var a = alpha[Math.floor(Math.random() * alpha.length)];
var b = alpha[Math.floor(Math.random() * alpha.length)];
var c = alpha[Math.floor(Math.random() * alpha.length)];
var d = alpha[Math.floor(Math.random() * alpha.length)];
var e = alpha[Math.floor(Math.random() * alpha.length)];
var f = alpha[Math.floor(Math.random() * alpha.length)];
var g = alpha[Math.floor(Math.random() * alpha.length)];
}
var code = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' ' + f + ' ' + g;
document.getElementById("main-captcha").value = code
}
,這裏是我的html代碼:
<label class="item item-input" id="login-input3">
<input type="text" readonly id="main-captcha">
<button type="submit" class="button button-small" ng-click="goCaptcha()">Refresh</button>
</label>
看起來不錯,但也許你的模板還沒有分配給它的正確的控制器。 –