select选择框切换内容显示的两种方法

1.ng-include 指令用于包含外部的 HTML 文件。包含的内容将作为指定元素的子节点。ng-include 属性的值可以是一个表达式,返回一个文件名。默认情况下,包含的文件需要包含在同一个域名下。
          1、标签方式:<ng-include src=“”>这里会被覆盖</ng-include>
          2、属性方式:<div ng-include=“”>这里会被覆盖</div>
          3、类方式:<div class=“ng-include:’ ’ ”>这里会被覆盖</div>

<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
    <script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>

<body ng-controller="myController">
<!--  template存放的是 templates中的每一个对象,相当于是item -->
    <select ng-model="template" ng-options="item.name for item in templates">
        <option value="">please choice</option>
    </select>
    当前加载的模板是{{template.name}} :{{template.url}}

    <div ng-include="template.url">

    </div>
    <p>我是广告给我打电话 办证</p>



</body>
<script src="angular.min.js"></script>
<script>

    angular.module('myApp',[])
            .controller('myController',['$scope',function($scope){

                $scope.templates = [
                    {name:'template1',url:'template1.html'},
                    {name:'template2',url:'template2.html'}
                ];

//                $scope.template = $scope.templates[0];

                $scope.myStyle = {
                    'background-color':'red'
                };


            }])



</script>


</html>
<!--  template1.html  -->
<h1>this is template one</h1>
<div style="width: 200px; height: 200px; background-color: aqua"></div>
<div style="width: 200px; height: 200px; background-color: red"></div>
<div style="width: 200px; height: 200px; background-color: blue"></div>
<div style="width: 200px; height: 200px; background-color: green"></div>
<div style="width: 200px; height: 200px; background-color: peru"></div>

<!--template2.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <p ng-style="myStyle">this is template two</p>

</body>
</html>

2.不同模块的div,就是在选择的时候,设置一个ng-change指令,里面传入数字,进行判断

<select  class="form-control" ng-model="othermodel.qc_type_code_oth_param" ng-change="choice(this.othermodel.qc_type_code_oth_param)" placeholder="请选择证件类型" style="width: 250px;height:34px;" >
                                                        <option value ="1">aaa</option>
                                                        <option value ="2">bbb</option>
                                                        <option value ="3">ccc</option>
                                                    </select>

 <div class="form-group" ng-if="filter.enterpriseType==2">
  </div>

$scope.choice = function(type) {
    $scope.filter.enterpriseType = type;
  }



  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值