點擊確定按鈕之後,再將編輯的資料展示在頁面上,用angular該怎麼實現`your name: 確定 Hello {{yourname}}!`
认证高级PHP讲师
那你的程式碼應該是這個樣子嘍:
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 }}!
可以將ng-model改為namehello{{confirmNmae}}在controller中實現賦值
那你的程式碼應該是這個樣子嘍:
可以將ng-model改為name
hello{{confirmNmae}}
在controller中實現賦值