[英]AngularJS : how to make object in objects to call subsequent http calls
I am a completely angular newbee, and I have a question about angular ng-repeat tags. 我是完全有角度的新手,并且对角度ng-repeat标签有疑问。
Here I have a list of devices and it is about to iterate each device in the html. 在这里,我有一个设备列表,它将要遍历html中的每个设备。
The question is, if each device will start to call a separate api, for example, like /devices/:device_id/get_some_thing_else using the given device_id from each device. 问题是,每个设备是否会开始使用每个设备的给定device_id来调用单独的api,例如/ devices /:device_id / get_some_thing_else。 How do i construct my angular page with which ng tag ?
如何使用ng标签构建我的角度页面?
I want the page to display a list of devices first before having each device to call a separate API. 我希望页面先显示设备列表,然后让每个设备调用单独的API。
The ng-repeat does not actually make any API calls. ng-repeat实际上不会进行任何API调用。 It just binds to an array
它只是绑定到一个数组
Say for example you had this variable in your JS file 假设您在JS文件中有此变量
$scope.devices = [{name: "device One"}, {name: "device Two"}, {name: "device Three"}];
then in your HTML you had 然后在您的HTML中
<div ng-repeat="device in devices">
<h1>{{device.name}}</h1>
</div>
when the page was rendered it would show 页面呈现时会显示
device One
device Two
device Three
where each line was wrapped in an H1 tag and also in a DIV tag 每行都包裹在H1标签和DIV标签中
You are responsible in your javascript file for specifying how the data gets into $scope.devices, usually through a factory. 您有责任在JavaScript文件中指定数据通常通过工厂进入$ scope.devices的方式。
Whenever the data in $scope.devices changes so will the corresponding HTML. 每当$ scope.devices中的数据更改时,相应的HTML也会更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.