AngularJS 用ng-show来绑定ng-model

AngularJS 用ng-show来绑定ng-model

<html lang="en" ng-app="myapp">
<head>
    <meta charset="UTF-8">
    <title>Titletitle>
    <script src="angular.min.js">script>
    <style>
      *{
        margin:0;
        padding:0;
      }
      .box{
        position: relative;
        margin: 0 auto;
        text-align: center;
        width: 600px;
        background: pink; 
      }
    style>
head>
<body>
  <div class="box" ng-controller="clt">
    <input type="text" ng-model="pty" placeholder="来这里输入数字吧">
    
    <div style="background: red" ng-show="pty>10" class="ng-hide" >
      <h1>你输了大于10的数我才出来的h1>
    div>
  div>
<script>
    var app=angular.module('myapp',[]);
    app.controller('clt',function($scope){

    })
script>
body>
html>

试一试:快去输入框里输入一次大于10的数和一次不大于10 的数看看它们区别吧!

你可能感兴趣的:(AngularJS)