简体   繁体   English

Angular JS-1链接到2st链接到3rd。 现在,我需要从第3个下拉列表中选择数据,以便在另一个文本区域中显示

[英]Angular JS- 1st Dropdown linked to 2nd linked to 3rd. Now I need selected data from 3rd drop down to display in another textarea

I have posted the script and the controller. 我已经发布了脚本和控制器。 From one drop down I goto the second one and from the second to third. 从一个下拉菜单中,我转到第二个,然后从第二个下拉至第三个。 for example amazon's website where you got categories then to electronics and then to mobile. 例如,在亚马逊网站上,您会获得类别,然后是电子产品,然后是移动产品。

Now I want to take that selected mobile and put it in another textarea. 现在,我想将所选的手机放到另一个文本区域中。

I am building a sales management project and I am new to angular JS. 我正在建立一个销售管理项目,对angular JS还是陌生的。

<!--This is the script--!> <script>
    function CategoryCntrl($scope) {
    $scope.categories = {'Electronics': {
    'Mobile': ['Samsung S6', 'Nokia 6', 'Motorola M2', 'Oneplus 3T'],
    'EarPhones': ['House of Marley H76', 'Sennheiser S789', 'Creative T242'],
    'Mouse': ['HP HP56', 'LG L11', 'Frontech F223']
    },
    'Clothing': {
    'T-Shirt': ['Levis T-Shirt 1231', 'PEPE T P6534', 'UCB T D7678'],
    'Shirt': ['Peter Englang P5466', 'Soldado S0944'],
    'Trouser': ['Vero Moda V6767', 'Arrow A6799']
    },
    'Books': {
    'Fiction': ['Red Serpant- Knox Vermount', 'Clove- Heather Tove', 'MajinBoo- Goku Gohan'],
    'Non-Fiction': ['Wings of Fire - APJ']
    }
    };
    }
    </script>
    ----------------------------------------------------------------------- <!--This is the controller--!>
    <div ng-controller="CategoryCntrl">
    Category: 
    <select class="select form-control" id="category" ng-model="productTypes" ng-options="category for (category, productTypes) in categories">
    <option value=''>Select</option>
    </select>
    Product Type: <select class="select form-control" id="productT" ng-disabled="!productTypes" ng-model="products" ng-options="productT for (productT,product) in productTypes"><option value=''>Select</option></select>
     Product: <select class="select form-control" id="product" ng-disabled="!products || !productTypes" ng-model="product"><option value=''>Select</option> <option ng-repeat="product in products" value='{{product}}'>{{product}}</option></select>        
    </div>
    ----------------------------------------------------------------------------
    <p>To be displayed here</p>

i have changed some areas in your code and seems to be working now. 我已经更改了代码中的某些区域,并且现在似乎可以正常工作。

Angular Controller Code 角度控制器代码

var app=angular.module('categoryApp',[]);
app.controller('categoryCntrl',['$scope',function($scope){

$scope.categories = {'Electronics': {
    'Mobile': ['Samsung S6', 'Nokia 6', 'Motorola M2', 'Oneplus 3T'],
    'EarPhones': ['House of Marley H76', 'Sennheiser S789', 'Creative T242'],
    'Mouse': ['HP HP56', 'LG L11', 'Frontech F223']
    },
    'Clothing': {
    'T-Shirt': ['Levis T-Shirt 1231', 'PEPE T P6534', 'UCB T D7678'],
    'Shirt': ['Peter Englang P5466', 'Soldado S0944'],
    'Trouser': ['Vero Moda V6767', 'Arrow A6799']
    },
    'Books': {
    'Fiction': ['Red Serpant- Knox Vermount', 'Clove- Heather Tove', 'MajinBoo- Goku Gohan'],
    'Non-Fiction': ['Wings of Fire - APJ']
    }
    };
 }]);

Code for HTML template HTML模板代码

<div ng-app="categoryApp">
<div ng-controller="categoryCntrl">
    Category: 
    <select class="select form-control" id="category" ng-model="productTypes" ng-options="category for (category, productTypes) in categories">
    <option value=''>Select</option>
    </select>
    Product Type: <select class="select form-control" id="productT" ng-disabled="!productTypes" ng-model="products" ng-options="productT for (productT,product) in productTypes"><option value=''>Select</option></select>
     Product: <select class="select form-control" id="product" ng-disabled="!products || !productTypes" ng-model="product"><option value=''>Select</option> <option ng-repeat="product in products" value='{{product}}'>{{product}}</option></select>        
    </div>

</div>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 根据第一个2下拉ID显示第三个下拉列表 - display 3rd drop down list based on 1st 2 dropdown ids 选择THIS元素的第1个第2个和第3个子元素 - Select 1st 2nd and 3rd child element of THIS element Puppeteer 打开下拉菜单,然后单击 [1st 2nd 3rd…] 选项 - Puppeteer Open Dropdown Menu and then click on [1st 2nd 3rd…] option 隐藏在第一和第二选择列表中选择的第三选择列表的选项 - Hide option of 3rd select list which are selected in 1st and 2nd select list 删除查询第一次未触发,第二次或第三次触发 - Delete query didn't fired on 1st time,it fired after 2nd or 3rd time 一旦我在第一个下拉列表中选择了不同的选项,如何重置第三个动态下拉列表? - How do I make my 3rd dynamic drop down reset once I pick a different option in the 1st drop down? 如何在选项标签 select 下拉列表 1st 2nd 3rd 4th 5th 中添加上标。 1ST 我想要 S 大写字母,但我试过 s 将转换为小写 - How to add superscript in option tag select dropdown 1st 2nd 3rd 4th 5th. 1ST I want S captial letters but i tried s will converted to small case 我的滑块仅显示第1和第3个滑块,但不显示表格的第2和第4个滑块 - My slider only shows 1st and 3rd slider but not the 2nd and 4th slider for table 我想做一个条件,如果我从第一个下拉列表中选择这个项目,它会只显示我在第二个下拉列表中选择的项目 - I want to make a condition in which if I select this item from 1st drop down show it shows me only selected items in 2nd drop down 在第一个下拉菜单被选中后显示第二个下拉菜单的内容。 - Show content of 2nd Drop down after 1st Drop down getting selected.
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM