AngularJS:我如何捕获函数中所选选项的值?

时间:2015-05-25 13:31:45

标签: angularjs cordova ionic-framework

我正在研究由angularJS组成的cordova应用程序。我有一个代码片段如下:

                <label class="item item-input item-select">
                <div class="input-label">
                    Select Team
                </div>
                <select>
                    <option ng-repeat="deviceEach in devices" id="{{deviceEach.id}}">{{deviceEach.name}}</option>
                </select>
            </label>

            <label class="item item-input">
                <input type="text" placeholder="Enter user Email" ng-model="newuser.username">
            </label>
            <br>
            <button ng-click="userSubmit(newuser)" class="button button-calm">
                Add User
            </button>

当用户点击添加用户按钮时,它应该捕获所选选项ID和输入的用户名的值。我可以捕获输入标签的值但是如何捕获select tag选择选项的值?

1 个答案:

答案 0 :(得分:0)

选择元素

使用ng-model

    Parse.Cloud.afterSave("YourObject", function(request) {
      var user = Parse.User.current();

      // check if the object was just created
      if(request.object.existed() == false){
        var newACL = new Parse.ACL();
        newACL.setPublicReadAccess(false);
        newACL.setPublicWriteAccess(false);
        newACL.setReadAccess(user.id,true);
        newACL.setWriteAccess(user.id,true);

        request.object.setACL(newACL);
        request.object.save();
      }
    });