Rumah > Soal Jawab > teks badan
点击确定按钮之后,再将编辑的数据展示在页面上,用angular该怎么实现
`your name: <input type="text" ng-model="yourname"/>
<button>确定</button>
Hello {{yourname}}!`
黄舟2017-05-15 16:57:04
Kemudian kod anda sepatutnya kelihatan seperti ini:
var model = angular.module('demo', []);
model.controller('DemoCtrl', function($scope){
$scope.user = {};
$scope.username = '';
$scope.confirm = function(){
$scope.user.username = $scope.username;
$scope.username = '';
};
});
your name: <input type="text" ng-model="username"/>
<button ng-click="confirm()">确定</button>
Hello {{ user.username }}!
天蓬老师2017-05-15 16:57:04
Anda boleh menukar model ng kepada nama
hello{{confirmNmae}}
Realisasikan tugasan dalam pengawal