从外部获取值ng-repeat in angular
Get value from outside ng-repeat in angular
如何从ng-repeat外部获取值?这是我从json
获取值的函数function($scope, $http) {
$http.get('https://www.mywebsite.com/images/getimages.php').
success(function(data, status, headers, config) {
$scope.walls = data.walls;
console.log($scope.walls);
}).error(function(data, status, headers, config) {
// called asynchronously if an error occurs
// or server returns response with an error status.
});
那么我有一个表:
<tr ng-repeat="wall in walls">
<td>{{wall.id}}</td>
<td><a href="#" ng-click="">{{wall.link}}</a></td>
</tr>
i将在表外的div中显示,因此在ng-repeat之外,{{墙。链接}}从td。我该怎么做呢?
您可以实现控制器功能来设置选定的墙壁对象:
function ($scope, $http) {
$http.get('https://www.mywebsite.com/images/getimages.php')
.success(function (data, status, headers, config) { /*...*/ })
.error(function (data, status, headers, config) { /*...*/ });
$scope.select = function (wall) {
$scope.selectedWall = wall;
};
}
和HTML中的
<table>
<tr ng-repeat="wall in walls">
<td>{{wall.id}}</td>
<td>
<a href="#" ng-click="select(wall)">{{wall.link}}</a>
</td>
</tr>
</table>
<div>{{selectedWall.link}}</div>
相关文章:
- RouteParams in Angular 2 rc1
- 要筛选的数组的管道值的含义:$select.search in angular
- Routing from Javascript lib in Angular JS 2
- $event with $scope in Angular
- 在 ng-repeat in angular-js 中插入竖条
- $http get in Angular Js
- concat 2 list in angular / js
- Authorization for window.location.href call in angular js
- ngcontroller in Angular JS
- 从 getElementById in angular js 中获取值
- 函数未在 window.plugins in Angular/Ionic 中运行
- Jquery prevAll() in Angular way
- OrderBy in Angular/html
- $http.get API in Angular JS
- showing data in angular
- ng-repeat in angular js
- LoDash: Reduce in Angular returns 0
- element.is() equivalent in Angular jqLite
- 如何显示叠加加载gif,同时完成我的http.Post in angular
- Previous Page in Angular.js