如何为1 ng重复注册2 ng模型

时间:2018-12-05 10:19:57

标签: javascript angularjs node.js mongodb mean-stack

我有两个名为bloodbankchaptersusers的集合,这是结构:

bloodbankchapters         users
chapter_name: String      name:String
chapter_id:String         branch_id:String
                          chapter_name:String

然后我有一个选择框,用于输出我的血统章的chapter_name,然后将其注册到user.chapter_name

<select class="form-control dropdown-toggle" ng-model="register.regData.branch" >
    <option ng-repeat="chapter in register.bloodbankchapters" >{{chapter.chapter_name}}</option>x`
</select>

<button ng-disabled="register.disabled" class="btn btn-primary" type="submit">Submit</button>

我的问题是,当我在选择框中选择名称时,如何也将bloodbankchapter.chapter_id注册到user.branch_id?

这是我注册用户的控制器:

.controller('regCtrl', function(User, Bloodbankchapter) {
        Bloodbankchapter.getBloodbankchapters().then(function(data) {
            app.bloodbankchapters = data.data.bloodbankchapters;            
        });

        var app = this;
        this.regUser = function(regData) {      
                User.create(app.regData).then(function(data) {
            });
        };
    })

0 个答案:

没有答案