产品线 产品 版本 代码是联动关系

ng-model 绑定数据 设置默认值
ng-options 填充option
ng-change 选项变化时的操作
截图如下:


html

 <!DOCTYPE html>
<html ng-app="a2_15">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
<title>使用指令复制元素</title>
<style type="text/css">
body {
font-size: 14px;
} ul {
list-style-type: none;
width: 400px;
} ul li {
float: left;
padding: 5px;
} ul li span {
float: left;
width: 50px
}
</style>
<script src="js/angular.min.js"></script> </head>
<body> <form name="temp_form" ng-controller="c2_15">
<div>
产品线:
<select ng-model="a"
ng-options="v.id as v.name for v in a_data"
ng-change="a_change(a)">
<option value="">--please select--</option>
</select>
</div> <div>
产品:
<select ng-model="b"
ng-options="v.id as v.name for v in b_data"
ng-change="b_change(b)">
<option value="">--please select--</option>
</select>
</div> <div>
版本:
<select ng-model="c"
ng-options="v.id as v.name for v in c_data"
ng-change="c_change(c)">
<option value="">--please select--</option>
</select>
</div> <div>
代码:
<select ng-model="d"
ng-options="v.id as v.name for v in d_data"
ng-change="d_change(d)">
<option value="">--please select--</option>
</select>
</div>
</form> <script type="text/javascript">
var a2_15 = angular.module('a2_15', []);
a2_15.controller('c2_15', ['$scope','$http', function ($scope, $http) {
// 默认值
$scope.a = "";
$scope.b = "";
$scope.c = "";
$scope.d = ""; // 填充选项
// 填充a
$http({
method:'POST',
url:'data/zz.php',
params:{
id:"",
type:"pl"
}
}).success(function (data,status,headers,config) {
$scope.a_data=data; // 填充b
$http({
method:'POST',
url:'data/zz.php',
params:{
id:$scope.a_data[0].id,
type:"p"
}
}).success(function (data,status,headers,config) {
$scope.b_data=data; // 填充c
$http({
method:'POST',
url:'data/zz.php',
params:{
id:$scope.b_data[0].id,
type:"r"
}
}).success(function (data,status,headers,config) {
$scope.c_data=data; // 填充d
$http({
method:'POST',
url:'data/zz.php',
params:{
id:$scope.c_data[0].id,
type:"c"
}
}).success(function (data,status,headers,config) {
$scope.d_data=data;
});
});
});
}); // change监听
$scope.a_change=function (a) {
// 填充b
$http({
method:'POST',
url:'data/zz.php',
params:{
id:$scope.a,
type:"p"
}
}).success(function (data,status,headers,config) {
$scope.b="";
$scope.b_data=data; // 填充c
$http({
method:'POST',
url:'data/zz.php',
params:{
id:$scope.b_data[0].id,
type:"r"
}
}).success(function (data,status,headers,config) {
$scope.c="";
$scope.c_data=data; // 填充d
$http({
method:'POST',
url:'data/zz.php',
params:{
id:$scope.c_data[0].id,
type:"c"
}
}).success(function (data,status,headers,config) {
$scope.d="";
$scope.d_data=data;
});
});
});
};
$scope.b_change=function (b) {
// 填充c
$http({
method:'POST',
url:'data/zz.php',
params:{
id:$scope.b,
type:"r"
}
}).success(function (data,status,headers,config) {
$scope.c="";
$scope.c_data=data; // 填充d
$http({
method:'POST',
url:'data/zz.php',
params:{
id:$scope.c_data[0].id,
type:"c"
}
}).success(function (data,status,headers,config) {
$scope.d="";
$scope.d_data=data;
});
});
};
$scope.c_change=function (c) {
$http({
method:'POST',
url:'data/zz.php',
params:{
id:$scope.c,
type:"c"
}
}).success(function (data,status,headers,config) {
$scope.d="";
$scope.d_data=data;
});
};
$scope.d_change=function (d) {
}
}]); </script>
</body>
</html>
 

  php

<?php
header("Content-Typent:text/json"); if($_GET["type"]=="pl"){
$stulist=array(
array('id'=>"1" ,'name'=>'产品线1' ),
array('id'=>"2" ,'name'=>'产品线2' )
);
echo json_encode($stulist);
}else if($_GET["type"]=="p"){
if($_GET["id"]=="1"){
$stulist=array(
array('id'=>"1" ,'name'=>'产品1' ),
array('id'=>"2" ,'name'=>'产品2' )
);
echo json_encode($stulist);
}else{
$stulist=array(
array('id'=>"1" ,'name'=>'产品3' ),
array('id'=>"2" ,'name'=>'产品4' )
);
echo json_encode($stulist);
}
}else if($_GET["type"]=="r"){
if($_GET["id"]=="1"){
$stulist=array(
array('id'=>"1" ,'name'=>'版本1' ),
array('id'=>"2" ,'name'=>'版本2' )
);
echo json_encode($stulist);
}else{
$stulist=array(
array('id'=>"1" ,'name'=>'版本3' ),
array('id'=>"2" ,'name'=>'版本4' )
);
echo json_encode($stulist);
}
}else if($_GET["type"]=="c"){
if($_GET["id"]=="1"){
$stulist=array(
array('id'=>"1" ,'name'=>'代码1' ),
array('id'=>"2" ,'name'=>'代码2' )
);
echo json_encode($stulist);
}else{
$stulist=array(
array('id'=>"1" ,'name'=>'代码3' ),
array('id'=>"2" ,'name'=>'代码4' )
);
echo json_encode($stulist);
}
}else{
$stulist=array(
array('id'=>"1" ,'name'=>'代码3' ),
array('id'=>"2" ,'name'=>'代码4' )
);
echo json_encode($stulist);
}
?>

  

angular $http 与form表单的select的更多相关文章

  1. React 之form表单、select、textarea、checkbox使用

    1.案例如下 import React from 'react'; /** * 非约束性组(类似defaultValue等属性,不可以程序修改): <input type="text& ...

  2. 前端 HTML form表单标签 select标签 option 下拉框

    <select></select> select里面通常跟option配合使用 <!DOCTYPE html> <html lang="en&quo ...

  3. form表单select联动

    下拉列表:二级联动菜单 Select对象的常用属性 options[]:返回所有option组成的一个数组: name:名称 value:option的value的值 length:设置或读取opti ...

  4. [原创]java WEB学习笔记62:Struts2学习之路--表单标签:form,表单标签的属性,textfield, password, hidden,submit ,textarea ,checkbox ,list, listKey 和 listValue 属性,select ,optiongroup ,checkboxlist

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

  5. select标签 禁止选择但又能通过序列化form表单传值到后台

    前言 项目开发中,我们可能会碰到这样的需求:select标签,禁止选择但又能通过序列化form表单传值到后台,但是当我们使用disabled="disabled"时发现,无法序列化 ...

  6. select发生改变使用js提交form表单(get传值)

    form表单如下: <form id="my_form" method="get" action=""> <input t ...

  7. form表单提交,后台怎么获取select的值?后台直接获取即可,和input方式一样。

    form表单提交,后台怎么获取select的值? 后台直接获取即可,和后台获取input的值方式一样. form提交后,后台直接根据select的name获取即可,即getPara("XXX ...

  8. form表单验证-Javascript

    Form表单验证: js基础考试内容,form表单验证,正则表达式,blur事件,自动获取数组,以及css布局样式,动态清除等.完整代码如下: <!DOCTYPE html PUBLIC &qu ...

  9. Form 表单提交参数

    今天因为要额外提交参数数组性的参数给form传到后台而苦恼了半天,结果发现,只需要在form表单对应的字段html空间中定义name = 后台参数名 的属性就ok了. 后台本来是只有模型参数的,但是后 ...

随机推荐

  1. [LeetCode] Implement Trie (Prefix Tree)

    Implement a trie with insert, search, and startsWith methods. Note:You may assume that all inputs ar ...

  2. js/jquery的应用

    1.JS限制文本框只能输入整数或小数 <script language="JavaScript" type="text/javascript"> f ...

  3. Mysql 索引实现原理. 聚集索引, 非聚集索引

    Mysql索引实现: B-tree,B是balance,一般用于数据库的索引.使用B-tree结构可以显著减少定位记录时所经历的中间过程,从而加快存取速度.而B+tree是B-tree的一个变种,My ...

  4. Ubuntu 下,修改 Mac address

    ifconfig    //    check Mac address sudo ifconfig eth0 down sudo ifconfig eth0 hw ether xx:xx:xx:xx: ...

  5. jQuery之Ajax--全局Ajax事件处理器

    1.这些方法用于注册事件处理器,用来处理页面上的任何 Ajax 请求,当某些事件触发后,这些事件处理器被调用.如果jQuery.ajaxSteup()中的 global 属性被设置为 true (这也 ...

  6. python day2:python 初识(二)

    大纲: 一.运算符 1.算数运算符 notice: 除法运算在python2.7和python3.x 的不同 2.比较运算符 3.赋值运算符 4.逻辑运算符 5.成员运算符 二.基本数据类型和方法介绍 ...

  7. sharedUserId

    android:sharedUserId sharedUserId的作用是让两个应用程序共享一个user id,我们都知道linux进程给每一个应用程序分配了一个独立的user id,所以如果两个或多 ...

  8. ArcGIS Server开发教程系列(8)ArcGIS API for Javascript-控件(小部件)

    1.     鹰眼 OverviewMap小部件用于在其关联的主地图内较清楚的当前鸟瞰图的范围.当主地图范围变化时,鹰眼图会自动在其空间内更新范围以保持和地图的当前范围保持一致,当鹰眼图空间的地图范围 ...

  9. docker windows 7 mysql安装使用教程

    mysql 1. 镜像的下载 Docker pull MySQL 可以从https://docker.cn/docker/mysql 看到官方的同步镜像. 大约400多M. 2. 运行 每个镜像都有一 ...

  10. 2Struts2配置----青软S2SH(笔记)

    实例的文件目录如下:两个配置文件(web.xml和struts.xml),一个UserAction.java,三个jsp. 1.配置Struts2应用环境: 下载Struts2的jar包,官网是:ht ...