有谁用过angularjs,怎么获取一个id的值
1 回答
翻翻过去那场雪
TA贡献2065条经验 获得超13个赞
<body onload='test()'>
<div ng-app="myApp" ng-controller="formCtrl">
<input type="text" id='aaaa' ng-model="user.firstName"><br>
<button ng-click="showvalue()">获取</button>
</div>
<script>
function test(){
alert(document.getElementById('aaaa').value);
}
var app = angular.module('myApp', []);
app.controller('formCtrl', function($scope) {
$scope.master = {firstName:"John1", lastName:"Doe"};
$scope.showvalue = function() {
alert($scope.user.firstName);
};
$scope.user = angular.copy($scope.master);
});
</script>
- 1 回答
- 0 关注
- 2035 浏览
添加回答
举报
0/150
提交
取消