angular.js - angular 怎么实现点击事件之后再进行数据绑定?
PHP中文网
PHP中文网 2017-05-15 16:55:04
0
2
586

点击确定按钮之后,再将编辑的数据展示在页面上,用angular该怎么实现
`your name: <input type="text" ng-model="yourname"/>
<button>确定</button>
Hello {{yourname}}!`

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
黄舟

Then your code should look like this:

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 }}!
Peter_Zhu

You can change ng-model to name
hello{{confirmNmae}}
Achieve value assignment in the controller

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!