javascript - Impress.js 和 AngularJS Controller

标签 javascript angularjs impress.js

我正在运行 AngularJS 应用程序/ Controller 。我的目标是在动态加载到我的主主页的页面上初始化和使用 impress.js 库。但是,当我尝试初始化库时,页面无法加载。附件是 Controller 和 html 文件的片段。

注意:当我将 impress() 对象打印到控制台时,它不为 null,并且具有所需的功能。我怀疑 impress() 对象没有正确连接到页面。

Controller :

'use strict';

// Create the angular module
var cmodule = angular.module('coverage', ['ngRoute'])

// Create the coverage controller
cmodule.controller('coverageController', function($scope) {

    console.log("Entering controller");
    function require(script) {
        $.ajax({
            url: script,
            dataType: "script",
            async: true,           // <-- This is the key
            success: function () {
                console.log(impress());
                impress().init();
            },
            error: function () {
                throw new Error("Could not load script " + script);
            }
        });
    }

    console.log("About to require");
    angular.element(document).ready(function () {
        require("/content/libraries/impress.js");
            });


    });

HTML 文件:

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=1024" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <title>My Coverage</title>
    <link rel="stylesheet" href="/content/styles/team1.css">
</head>
<body class="impress-not-supported">
    <!--
    For example this fallback message is only visible when there is `impress-not-supported` class on body.
    -->
    <div class="fallback-message">
        <p>Your browser <b>doesn't support the features required</b> by impress.js, so you are presented with a simplified version of this presentation.</p>
        <p>For the best experience please use the latest <b>Chrome</b>, <b>Safari</b> or <b>Firefox</b> browser.</p>
    </div>

    <!-- Now the fun begins -->

    <div id="impress">

        <!-- The background image -->
        <div class="present" data-x="0" data-y="0">
            <!-- Place Image here -->
        </div>

        <!-- Example content -->
        <div id="url-ident" class="step" data-x="0" data-y="0">
            <q>Ready to view your coverage?</q>
        </div>

        <!-- Example content -->
        <div id="step1" class="step" data-x="500" data-y="0">
            <p>Questions start here!</p>
        </div>

    </div> <!-- /div impress -->

    <script type="text/javascript" src="/content/libraries/impress.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
    <!--script type="text/javascript">impress().init();</script-->

</body>
</html>

最佳答案

这个问题已通过使用 jmpress.js 库修复,发现 here .

关于javascript - Impress.js 和 AngularJS Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30915571/

相关文章:

javascript - 在 Node.js 中上传和检索图像?

javascript - 如何让我的网站检测到某些 Web 浏览器?

javascript - 如何查看苹果收据的有效期?

javascript - jQuery 插件事件监听器未触发或绑定(bind)

angularjs - 如何使用 css 在 li 之间留出边距?

javascript - 如何让 ImpressJS 在 IE10 上工作?

javascript - 为什么我的请求正文为空?

javascript - Angular .js : How to reduce font size dynamically based on characters' length?

flash - 将 HTML5 转换为 Flash

javascript - 向 impress.js 添加事件监听器