如何在Angular JS中选择选项?

时间:2015-04-24 18:30:15

标签: angularjs

我已经通过php生成了SELECT列表。 我如何在此选择列表中选择一些选项?

<select name="language[]" ng-model="formData.language" id="language" ng-required="true">
<option value="72" selected="selected">Fulfulde</option>
</select>

2 个答案:

答案 0 :(得分:1)

尝试使用ng-options属性

<select ng-model="myColor" ng-options="color.name group by color.shade disable when color.notAnOption for color in colors"> </select>

有关详情,请仔细阅读link

答案 1 :(得分:0)

我建议你使用<select ng-model="myColor" ng-options="color.name for color in colors"></select> 指令来处理选择框。

<?php
//include config
require_once('includes/config.php');

//check if already logged in move to home page
if ($user->is_logged_in()) {
    header('Location: index.php');
}

//process login form if submitted
if (isset($_POST['submit'])) {

    $username = filter_input(INPUT_POST, 'username');
    $password = filter_input(INPUT_POST, 'password');

    if ($user->login($username, $password)) {
        $_SESSION['username'] = $username;
        header('Location: memberpage.php');
        exit;
    } else {
        $error[] = 'Wrong username or password or your account has not been activated.';
    }
}//end if submit
//define page title
$title = 'Login';

//include header template
require('layout/header.php');
?>

Working Plunkr