答案 0 :(得分:0)
如果您正在使用角度js,那么关注事物可以帮助您。
var app = angular.module('app', [ ]);
app.controller('MyController', function($scope) {
$scope.setValue = function(number){
$scope.myValue = number;
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.22/angular.min.js"></script>
<body ng-app="app">
<div ng-controller="MyController">
<button ng-click=setValue('One')>One</button>
<button ng-click=setValue('Two')>Two</button>
<button ng-click=setValue('Three')>Three</button>
<input value="{{myValue}}" />
</div>
</body>