沒有效果怎麼可能刪除與復位按鈕UI元素在下面的代碼Angular.js復位按鈕NG-重複
<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" />
<input type="reset" id="reset" value="Reset" />
<ul>
<li ng-repeat="(key,val) in ret">{{key}} = {{val}}</li>
</ul>
</form>
<script>
function Ctrl($scope) {
$scope.ret = {}
$scope.reset = function() {
$scope.ret = {}
}
$scope.submit = function() {
var str = $scope.text;
var ret = $scope.ret
for (x = 0, length = str.length; x < length; x++) {
var l = str.charAt(x);
ret[l] = (isNaN(ret[l]) ? 1 : ret[l] + 1);
}
$scope.ret = ret
}
}
</script>
</body>
</html>
預先感謝您。
謝謝。 NG-控制器= 「Ctrl」 鍵之上缺失<形式NG-INIT = 「秀=真」 NG-提交= 「提交()」 NG-控制器= 「Ctrl」 鍵> – user977828
@ user977828添加回來。我正在玩jsfiddle並將其提取到外包裝。謝謝。 – zsong