亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

angularJs里單選框radio怎么使用ng-model

angularJs里單選框radio怎么使用ng-model

慕萊塢森 2019-03-15 16:10:18
angularJs里單選框radio怎么使用ng-model
查看完整描述

2 回答

?
慕雪6442864

TA貢獻1812條經驗 獲得超5個贊

使用ng-model把radio綁到一個變量上,ng-value使用表達式來表示值。選中時它的值就是ng-value的值了。測試代碼如下:
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>radio的綁定</title>
<script src="angular.js"></script>
<style>

</style>
</head>

<body ng-app="app">
<div ng-controller="appCon">
<form ng-submit="ok()">
<div>
<input type="radio" name="a" ng-value="a" ng-model="c">11 <input type="text" ng-model="a">
<input type="radio" name="a" ng-value="b" ng-model="c">22<input type="text" ng-model="b">
</div>
<h1>{{c}}<h1>
<input type="submit" value="submit">
</form>
</div>

<script>

var app = angular.module('app', []);

app.controller('appCon', function($scope) {

$scope.ok = function(){
console.dir($scope.c);
}
});
</script>
</body>

</html> 

查看完整回答
反對 回復 2019-03-20
  • 2 回答
  • 0 關注
  • 2089 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號