AngularJS Form Selecet值

时间:2016-04-07 14:58:41

标签: html angularjs intel-xdk

您好我开始使用AngularJS和Intel XDK尝试制作表单并使用JSON通过AJAX发送数据。我首先尝试显示我从输入和comboBox获得的信息但是我在使用comboBox时遇到了一些麻烦。我按照w3schools.com的指南进行了操作,但我无法使其正常工作。

<div ng-app="myApp" ng-controller="myCtrl">
    <label class="item item-input item-select">
        <div class="input-label">
            Tipo de Sangre
        </div>
        <select ng-model="selectedName" ng-options="x for x in names"></select>
    </label>
</div>

<script>
    var app = angular.module('myApp', []);
    app.controller('myCtrl', function($scope) {
        $scope.region = ["Región de Los Ríos"];
        $scope.names = ["A+", "A-", "B+", "B-", "O+", "O-", "AB+", "AB-"];
        $scope.comuna = ["Corral", "Lanco", "Los Lagos", "Máfil", "Mariquina", "Paillaco", "Panguipulli", "Valdivia", "Futrono", "La Unión", "  Lago Ranco", "Río Bueno" ];
    });
</script>

<h3>Hello {{event.rut + " " + event.nombre + " " + event.apellido + " " + event.telefono + " " + selectedRegion + " " + selectedComuna + " " + selectedName}}</h3>

1 个答案:

答案 0 :(得分:1)

这里我只将变量启动为空:

app.controller('MainCtrl', function($scope) {
    $scope.name = 'World';
    $scope.selectedName = '';
    $scope.region = ["Región de Los Ríos"];
    $scope.names = ["A+", "A-", "B+", "B-", "O+", "O-", "AB+", "AB-"];
    $scope.comuna = ["Corral", "Lanco", "Los Lagos", "Máfil", "Mariquina", "Paillaco", "Panguipulli", "Valdivia", "Futrono", "La Unión", "  Lago Ranco", "Río Bueno" ];
});

这是掠夺者 https://plnkr.co/edit/WlqV02JsA8z43j33wuZ2?p=preview

您的h3标签位于控制器范围之外,因此不打印任何内容。在div中包含h3标签:

<div ng-app="myApp" ng-controller="myCtrl">
    <label class="item item-input item-select">
        <div class="input-label">
            Tipo de Sangre
        </div>
        <select ng-model="selectedName" ng-options="x for x in names"></select>
    </label>
<h3>Hello {{event.rut + " " + event.nombre + " " + event.apellido + " " + event.telefono + " " + selectedRegion + " " + selectedComuna + " " + selectedName}}</h3>
</div>

希望有所帮助