【发布时间】:2019-08-01 06:20:17
【问题描述】:
app.controller('contentixaeng', function ($scope, $http) {
$scope.subject = function(){
$scope.code=101;
};
$http({
method: "POST",
data:{
'subj_code':$scope.code, 'action':'singledata'
},
url: "pages/Entries/connectixa.php"
}).then(function mySuccess(response) {
$scope.users = response.data;
}, function myError(response) {
$scope.error = response.data;
});
});
我正在尝试将 $scope.code 的值传递给 HTTP 服务中的数据。它无法正常工作,并且没有数据值显示为输出。相反,我收到错误“ng-repeat dupes”。
通过这一行调用函数主题
<li class="nav-item" ng-contoller="contentixaeng"><a class="nav-link" href="#" ui-sref="ixaeng" ng-click="subject()" >English</a></li>
如果我更改如下所示的代码,那么它可以工作
app.controller('contentixaeng', function ($scope, $http) {
$scope.subject = function(){
$scope.code=101;
};
$http({
method: "POST",
data:{
'subj_code':101, 'action':'singledata'
},
url: "pages/Entries/connectixa.php"
}).then(function mySuccess(response) {
$scope.users = response.data;
}, function myError(response) {
$scope.error = response.data;
});
});
我希望根据点击事件将不同的数据传递给数据库搜索。
【问题讨论】:
标签: angularjs angularjs-directive angular-ui-router angular-material