html页面包含整个代码。
<body ng-app="mymodule">
<label>Search:</label><input type="text" placeholder="Search Here" ng-model="search" />
<table ng-controller="cntrlbtn" class="table table-bordered">
<tr ng-repeat="resp in inp">
<td></td>
</tr>
</table>
<table ng-controller="mycontroller" class="table table-bordered">
<tr ng-repeat="resp in res | filter :search" >
<td colspan="1"><input type="button" class="btn btn-danger" value="{{resp.ct_nm}}" ng-click="click(resp.ct_nm);" /></td>
</tr>
</table>
<span ng-repeat="resp in res" ng-controller="mycontroller">
<button ng-click="click(resp.ct_nm);">{{resp.ct_nm}}</button>
</span>
<table ng-controller="mycontroller" class="table table-bordered">
<tr ng-repeat="resp in inp">
<td colspan="1">{{resp.sbct_nm}}</td>
</tr>
</table>
并且角度脚本在这里。主要的API,即http://localhost/Publish/ProductCategory/GET'正在工作。但是第二个API,即$ scope.click中的API不起作用。在外面测试API是给出值。
在谷歌浏览器开发人员工具中,它正在点击API但没有得到任何响应。
var appmodule = angular.module('mymodule', []).controller('mycontroller', function ($scope, $http,$location,$anchorScroll) {
$http.get('http://localhost/Publish/ProductCategory/GET').then(function (response) {
$scope.res = response.data;
});
$scope.click = function (btnval) {
debugger;
$http.get('http://localhost/Publish/ProductSubCategory/GET?pdnm=Laptop').success(function (btnres) {
$scope.inp = btnres;
});
};
});
答案 0 :(得分:0)
我刚试过你的代码,它运行正常。但是你需要删除所有额外的
ng-controller="mycontroller"
在你的html中,因为它们会导致角度错误,所以它看起来像这样:
<label>Search:</label><input type="text" placeholder="Search Here" ng-model="search" />
<table class="table table-bordered">
<tr ng-repeat="resp in inp">
<td></td>
</tr>
</table>
<table class="table table-bordered">
<tr ng-repeat="resp in res | filter :search" >
<td colspan="1"><input type="button" class="btn btn-danger" value="{{resp.ct_nm}}" ng-click="click(resp.ct_nm);" /></td>
</tr>
</table>
<span ng-repeat="resp in res" >
<button ng-click="click(resp.ct_nm);">{{resp.ct_nm}}</button>
</span>
<table class="table table-bordered">
<tr ng-repeat="resp in inp">
<td colspan="1">{{resp.sbct_nm}}</td>
</tr>
</table>