gpt4 book ai didi

javascript - 根据下拉列表中的选择更改段落文本 - Angular

转载 作者:行者123 更新时间:2023-12-02 13:56:49 25 4
gpt4 key购买 nike

我试图根据用户从下拉菜单中选择的内容来更改信件中的段落,但我无法让它工作。

我不确定 ng-show/hide 是否可行,或者 ng-options 是否可行。我对此非常迷失。我绞尽脑汁一整天了。

app.controller('letterCreateCtrl', function($scope) {
$scope.selectItemsFilterCriteria = [
{id: 1, name: "An event that occurred in the past 12 months"},
{id: 2,name: "child/family got a new dog"},
{id: 3, name: "child/family got a new cat"}
];

});
<select ng-options="item.name for item in selectItemsFilterCriteria" name="field_event">
<option value="" disabled hidden selected>An event that occurred in the past 12 months</option>
<optgroup label="Pets">
<option value="Pets-1">Child/family got a new dog</option>
<option value="Pets-2">Child/family got a new kitten</option>
<option value="Pets-3">Child/family got a new rabbit</option>
</optgroup>
<optgroup label="Development">
<option value="Development-1">Baby began sitting up on their own</option>
<option value="Development-2">Child learned to walk</option>
<option value="Development-3">Child started to get baby teeth</option>
</optgroup>
</select>


<p>paragraph to change ipsum ipsum</p>

最佳答案

查看 fiddle - here

<div ng-controller="testCtrl">
<select ng-options="item.name for item in selectItemsFilterCriteria" name="field_event" ng-model="paragraphToShow">
</select>

<p>{{paragraphToShow.para}}</p>
</div>

关于javascript - 根据下拉列表中的选择更改段落文本 - Angular,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40625593/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com