假设我正在使用 Angular 进行数据绑定并阻止我使用重复代码:
<div id="{{slide.id}}" class="step" data-x="{{slide.x}}" data-y="{{slide.y}}" data-z="{{slide.z}}" data-rotate-x="{{slide.rotateX}}" data-rotate-y="{{slide.rotateY}}" data-rotate-z="{{slide.rotateY}}" data-scale="{{slide.scale}}" ng-repeat="slide in slides">
{{slide.content}}
</div>
正如你所看到的,我准备div
好让它遍历这个 JSON 文件中的每个对象:
[
{
"id":"overview",
"x":3000,
"y":1500,
"z":0,
"rotateX":0,
"rotateY":0,
"rotateZ":0,
"scale":10,
"content":"content2"
},
{
"id":"slide_1",
"x":1600,
"y":1800,
"z":-10,
"rotateX":0,
"rotateY":0,
"rotateZ":0,
"scale":1,
"content":"content1"
},
]
该文件使用此完美加载:
App = angular.module('App', []);
App.controller('SlideCtrl', ($scope, $http) ->
$http.get('js/slides.json')
.then((res)->
$scope.slides = res.data
)
)
但不知何故,输出看起来像这样:
有没有人真正实现了角度和印象?