【发布时间】:2016-03-23 21:56:55
【问题描述】:
我开始构建一个 Electron 应用程序,当我尝试在其中运行角度分布时遇到了一些问题。
对于 Angular 应用程序,我使用 yeoman 和 grunt 进行构建。如果我使用 grunt serve 开发 Angular 应用程序并在 localhost:9000 上运行它,Electron 应用程序可以很好地选择应用程序。但是,如果我运行 grunt build 并将 Electron 应用程序指向静态文件,则会出现一些角度错误。
[$injector:modulerr] Failed to instantiate module clientApp due to:
Error: [$injector:modulerr] Failed to instantiate module ngResource due to:
Error: [$injector:nomod] Module 'ngResource' 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.
在电子应用程序中,我使用 express 运行服务器,并且我还尝试在 localhost:8000 选择通过 express 运行 angular 应用程序。那也没有用。我还尝试运行另一个部署在我的服务器上并在浏览器中正常工作的 Angular 应用程序 - 在 Electron 中不起作用。所有尝试都出现相同的错误。
我还必须提到,在所有情况下,如果我在浏览器中打开 Angular 应用程序,它就可以正常工作。
这是电子密码:
app.on('ready', function() {
// Create the browser window.
mainWindow = new BrowserWindow({width: 1024, height: 764, title: "uMaster"});
// and load the index.html of the app.
var url = path.join(__dirname, "dist", "index.html");
url = "file://" + url;
console.log(url);
// mainWindow.loadURL(url); ---- this is not working in Electron
// mainWindow.loadURL("http://localhost:8000"); -- not working when served by express
mainwindow.loadURL("http://localhost:9000"); // working when angular runs with grunt serve
// Emitted when the window is closed.
mainWindow.on('closed', function() {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
/* ----------------------- */
});
【问题讨论】:
-
听起来你错过了对
angular-resource.min.js的引用 -
不是这样,如果修改了angular模块的顺序,只会说第一个模块没有被引用,它会崩溃。参考显然在那里,因为它在电子之外运行。
标签: angularjs node.js electron