點擊確定按鈕之後,再將編輯的資料展示在頁面上,用angular該怎麼實現
`your name:
Hello {{yourname}}!`
黄舟2017-05-15 16:57:04
那你的程式碼應該是這個樣子嘍:
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 }}!