Angular函数根据下拉菜单中的选择来改变json

angular function to change json based on selection from dropdown

本文关键字:选择 改变 json 函数 下拉菜单 Angular      更新时间:2023-09-26

这里是Angular新手。

我有这个柱塞,那里有一个列表。列表中的一个项目有一个标志符号,当点击时打开一个模态。该标志只应用于列表中primary_program设置为true的一个项。

这是我的json文件的格式:
{
        "student": 2773951, 
        "credits_completed": 26, 
        "academic_program_gpa": null, 
        "primary_program": true, 
        "academic_program": {
            "id": 596, 
            "acad_program_category": 2, 
            "acad_program_type": 2, 
            "program_title": "Associate in Sciences Degree", 
            "required_credits": 60, 
            "min_gpa": 2.0, 
            "description": "", 
            "colleges": [
                200, 
                300, 
                400, 
                500, 
                600, 
                700, 
                800
            ]
        }
    }

在模态中,我有相同的下拉列表。当一个程序被选中时,我希望应用程序将primary_program的值更改为true,选择为true,列表的其余部分更改为false。我如何写一个函数来实现这个功能?我尝试使用ng-change()函数。但它不会对json做任何更改。我该如何处理这个问题?

<select ng-change="onChange()">