【发布时间】:2018-07-08 08:52:03
【问题描述】:
这里有完整的代码。
<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,但没有得到任何响应。
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;
});
};
});
【问题讨论】:
-
在浏览器中输入,是否有效? 'localhost/Publish/ProductCategory/GET',需要提供端口吗?
-
是的,它正在浏览器中。
-
将console.log(btnres) 放在这一行上方 $scope.inp = btnres;你得到了什么?
-
它没有进入 $http.get();
-
删除调试器;
标签: javascript jquery angularjs angular-ui-router angularjs-scope