我点击了标签
打开了简单的表单<form name="instructions" class="form form-horizontal" ng-controller="InstructionsPage">
<div class="form-group">
<label for="instruction">Instructions</label>
<textarea id="instruction" rows="5" class="form-control" ng-model="instructions">
</textarea>
</div>
<button class="btn btn-primary" data-ng-click="saveInstructions()">Save</button>
</form>
和相关的控制器
angular.module('myApp.controllers')
.controller('InstructionsPage', ['$scope', function ($scope) {
use strict';
$scope.saveInstructions = function() {
var data = $scope.instructions;
// post request with data from textfield inside
}
}]);
如何使用GET-request接收数据以使用默认/以前保存的数据填充文本字段?谢谢!
答案 0 :(得分:1)
您可以从控制器更新绑定到$scope.instructions
<textarea>
的{{1}}变量,如下所示:
ng-model