AngularJS 및 Reveal.js를 사용하여 슬라이드 쇼를 만들고 있습니다. 공개하면 양식이 필요합니다.* wrapper * 지시어 작성 선언적 AngularJS
<div class="slides">
<section>
</section>
</div>
가로 슬라이드 용.
<div class="slides">
<section>
<section>
</section>
</section>
</div>
나는 각도를 사용하여이 페이지를 렌더링하고있다 : 수직 슬라이드는 두 개의 섹션이 있지만하여 여러개로
<div ng-app='myApp' class="reveal">
<div class="slides" ng-controller='MyController'>
<section slide ng-repeat="slide in slides">
</section>
</div>
</div>
<script src="https://raw.github.com/hakimel/reveal.js/master/js/reveal.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js"></script>
</body>
</html>
슬라이드 는 수직해야 단계를 반복합니다. 다른 모든 것들은 수평 적이어야합니다. 컨트롤러는 단계를 반환하고 설정은 공개 :
function MyController($scope) {
$scope.slides = [
{ 'steps': ['a'] },
{ 'steps': ['b1', 'b2'] },
{ 'steps': ['c1'] }
];
setTimeout(function() {
Reveal.initialize({
loop: false,
transition: Reveal.getQueryHash().transition || 'none'
});
}, .1 * 1000);
}
이 지침은 단계의 주위에 새로운 요소와 속성을 추가 할 필요가있다. 이 각도 코드처럼 보이는 것을
app.directive('slide', function() {
var wrapContent = function (content) {
return '<h1>' + content + '</h1>';
};
return {
restrict: 'A'
,link: function (scope, element, attrs, controller) {
// resorting to imparative jQuery way
if (scope.slide.steps.length == 1) {
element.html(
wrapContent(scope.slide.steps[0])
);
} else {
var sections = '';
for (i=0,len=scope.slide.steps.length; i < len; ++i) {
sections +=
'<section ' +
function() {
result = '';
if (i !== len-1) {
result = 'data-autoslide="1000" ';
}
return result;
}() +
'>' +
wrapContent(scope.slide.steps[i]) +
'</section>';
}
element.html(sections);
}
}
}
});
어떻게이 같은 쓰는가 : 다음 지침처럼 내 필수, 추한 당황, jQuery를 무엇입니까? jsfiddle
컴파일, 링크, 바꾸기를 모두 시도해 보았습니다.
링크가 끝날 때 3 자 리브를 초기화하면 어리석은'setTimeout'이 제거됩니다. 고마워. OTOH, 이것은 아직도 각성보다는 긴급하게 느낀다. – zhon
확실히 Angular에서 볼 수있는 고전적인 선언 스타일이 반드시 필요합니다. 하지만 Reveal.js는 기대하는 DOM에 매우 구체적이어서 무엇을 렌더링할지에 대한 논리가 복잡하기 때문에 실제 프로젝트에서이 방법을 쓰는 것이 더 읽기 쉽다고 생각합니다.(실제로이 지시어의 선언적 버전을 아직 만들지 못했습니다.) –