在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML5/ angularJS根據(jù)選擇的radio顯示對(duì)應(yīng)的p

angularJS根據(jù)選擇的radio顯示對(duì)應(yīng)的p

有三個(gè)radio分別對(duì)應(yīng)三個(gè)p,選擇radio1顯示p1,選擇radio2顯示p2,以此類(lèi)推,其他的p隱藏。
<div>

<div>
    <input type='radio'>radio1
    <input type='radio'>radio2
    <input type='radio'>radio3
</div>
<div>
    <p>p1</p>
    <p>p2</p>
    <p>p3</p>
</div>

</div>

我知道大概是用ng-if,ng-model,但是不知道具體咋使用,有大神可以講講嗎,在線(xiàn)等,小弟不勝感激,抱拳。

回答
編輯回答
初念
<!DOCTYPE html>
<html lang="en" ng-app="App">
<head>
    <meta charset="UTF-8">
    <meta name="fragment" content="!">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="address=no">
    <title>Title</title>
    <script src="https://cdn.bootcss.com/angular.js/1.5.3/angular.js"></script>
</head>
<body ng-controller="Main">
<div>
    <input type='radio' value="1" ng-model="sex"> V1
    <input type='radio' value="2" ng-model="sex"> V2
</div>
{{sex}}
<div>
    <p ng-if="sex==1">p1</p>
    <p ng-if="sex==2">p2</p>
</div>
<script>
  angular.module('App', []).controller('Main', [
    '$scope', function($scope) {
      $scope.sex = 1;
    }]);
</script>
</body>
</html>

效果

clipboard.png

clipboard.png

2017年12月23日 17:16