所以,继续this question
我现在我的模块都在bower和npm中,我可以将它导入到我的项目并在app.module中声明它,甚至尝试在我的控制器中使用它:
的index.html:
<script src="bower_components/google-closure-library/closure/goog/base.js"></script>
app.module.js:
angular
.module('drugQualityDataManagerApp', [
'ngStorage',
'ngResource',
'ngCookies',
'ngAria',
'web-gl-earth2',
uploadData.controller.js:
$scope.initializeMapWebGL = function(){
var earth = new webGlEarth.map('earth_div');
webGlEarth.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(earth);
var marker = webGlEarth.marker([51.5, -0.09]).addTo(earth);
marker.bindPopup("<b>Hello world!</b><br>I am a popup.<br /><span style='font-size:10px;color:#999'>Tip: Another popup is hidden in Cairo..</span>", {maxWidth: 150, closeButton: true}).openPopup();
var marker2 = webGlEarth.marker([30.058056, 31.228889]).addTo(earth);
marker2.bindPopup("<b>Cairo</b><br>Yay, you found me!", {maxWidth: 120, closeButton: false});
var markerCustom = webGlEarth.marker([50, -9], '/img/logo-webglearth-white-100.png', 100, 24).addTo(earth);
earth.setView([51.505, 0], 6);
};
uploadData.html:
<style>
html, body{padding: 0; margin: 0; background-color: black;}
#earth_div{top: 0; right: 0; bottom: 0; left: 0; position: absolute !important;}
</style>
<title>WebGL Earth API: Markers</title>
<body onload="initialize()">
<div id="earth_div"></div>
</body>
但是,当然,这不是那么直接,问题来自webglearth2的依赖关系,这个应用程序强烈依赖于google-closure-library,而angular不喜欢它,我已经尝试包装main.js文件,如:
(function () {
'use strict';
angular.module('web-gl-earth2', []).provider('webGlEarth');
我将google-closure-library添加到我的bower_components和app.module.js,但我仍然感到害怕:
Uncaught ReferenceError: goog is not defined
所以,我留下了一个问题:那里是否有一个自动包装器可以帮助我将这个模块集成到角度,或者我注定要重新编写整个源代码以使其“角度可爱”?