【问题标题】:Angularjs and Intel XDK doesn't mix wellAngularjs 和 Intel XDK 不能很好地混合
【发布时间】:2014-03-12 22:05:25
【问题描述】:

我一直在尝试使用 Angularjs 和 Intel XDK 构建应用程序,但似乎 XDK 从 html 中剥离了一些标签,因此 Angularjs 无法工作。

代码如下:

<script src='intelxdk.js'></script>
<script src='vendors/angular.js'></script>
<script type="text/javascript">
    var onDeviceReady=function(){
        intel.xdk.device.hideSplashScreen();
        var bApp = angular.module('bApp', []);
        bApp.controller('MenuCtrl', function ($scope) {
           $scope.test = 'Hello world!'; 
        });

    };
    document.addEventListener("intel.xdk.device.ready",onDeviceReady,false);
</script>

<div ng-app="bApp">
    <div id="MenuCtrl" ng-controller="MenuCtrl">
        {{test}}
    </div>

</div>

这是控制台中的错误消息:

Uncaught Error: [$injector:modulerr] Failed to instantiate module bApp 
due to: Error: [$injector:nomod] Module 'bApp' is not available! 
You either misspelled the module name or forgot to load it. 
If registering a module ensure that you specify the dependencies as 
the second argument.

有什么想法吗?谢谢

【问题讨论】:

    标签: javascript angularjs javascript-framework intel-xdk


    【解决方案1】:

    这似乎是一个范围问题!

    将 bApp 相关的代码移出 onDeviceReady 函数解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-07-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-06-23
      • 2010-09-28
      • 1970-01-01
      相关资源
      最近更新 更多