这是我的php和angular代码。我的值来自数据库中的选择ng-options。我想将参数中的值设置为默认值到select组件。我根本不知道。通过很多网站和问题,但无法搞清楚。事实上,我对angular和php非常新。
php代码:
<td><select name="topicname" ng-model="topic" ng-options='x.topic_id as x.description for x in topics' id="yashselect" >
</select><p>{{topic.topic_id}}{{topic}}</p><input type="hidden" name="daytopic" value="{{topic.topic_id}}">
</td>
.js链接代码:
var app = angular.module('myApp', []);
app.controller('tasksController', function($scope, $http) {
$scope.topic = $scope.getTopics;
$scope.topics = "SSO";
$scope.getTopics = function (task,sol){
// alert(task+sol)
$http.get("ajax/getTopics.phptask="+task+"&sol="+sol).success(function(data){
$scope.topics = data;
});
};
});