题
我有问题将文本设置为Onsen中的文本输入。如何使用JavaScript中的OnSen中的文本输入文本或值?
抱歉我的英语不好。解决方案
在AngularJS中,根据NG模型的价值Chagnes。
例如,HTML是
<div ng-controller="MyCtrl" ng-init="text = 'Hello'">
<ons-text-input
ng-model="text"
style="display: block; width: 100%" value="OK">
</ons-text-input>
<div ng-click="setText('changed1');">Change 1!</div>
<div ng-click="setText('changed2');">Change 2!</div>
<div ng-click="setText('changed3');">Change 3!</div>
</div>
.
和js代码是
app = angular.module('myApp', ['onsen.directives']);
app.controller('MyCtrl', function($scope) {
$scope.setText = function(str) {
$scope.text = str;
};
});
.
当变量文本为NG模型本身发生变化时,输入的值会自动更改。
不隶属于 StackOverflow