0
我有下面的代碼,但是當我按提交沒有發生當我按下提交沒有發生
<html ng-app>
<head>
<script src="http://code.angularjs.org/1.2.0rc1/angular.min.js"></script>
</head>
<body>
<form ng-submit="submit()" ng-controller="Ctrl">
Enter text and hit enter:
<input type="text" ng-model="text" name="text" />
<input type="submit" id="submit" value="Submit" />
</form>
<script>
function Ctrl($scope) {
var str = $scope.text;
var ret = {};
for(x = 0, length = str.length; x < length; x++) {
var l = str.charAt(x);
ret[l] = (isNaN(ret[l]) ? 1 : ret[l] + 1);
}
for(key in ret) {
alert(key + ' :: ' + ret[key]);
}
}
</script>
</body>
</html>
我做了什麼錯?
謝謝你這是工作 – user977828